diff options
| author | 王宽 <[email protected]> | 2024-08-15 03:54:42 +0000 |
|---|---|---|
| committer | 王宽 <[email protected]> | 2024-08-15 03:54:42 +0000 |
| commit | cba6a89bade113b208fc24411300a931a64c5db1 (patch) | |
| tree | 086b3a7977fe2e512c283b928b82641efb1668ca /groot-common/src/main | |
| parent | 3b5e06b70db295b3f4ec8d1e455a095009c82bc0 (diff) | |
| parent | f7927f9ce7e651f925db8fed2cb4e89f5b5e10c8 (diff) | |
Merge branch 'feature/table' into 'develop'
Feature/table
See merge request galaxy/platform/groot-stream!92
Diffstat (limited to 'groot-common/src/main')
| -rw-r--r-- | groot-common/src/main/java/com/geedgenetworks/common/utils/JsonPathUtil.java | 33 | ||||
| -rw-r--r-- | groot-common/src/main/resources/udf.plugins | 3 |
2 files changed, 35 insertions, 1 deletions
diff --git a/groot-common/src/main/java/com/geedgenetworks/common/utils/JsonPathUtil.java b/groot-common/src/main/java/com/geedgenetworks/common/utils/JsonPathUtil.java index dcba58c..0823ddc 100644 --- a/groot-common/src/main/java/com/geedgenetworks/common/utils/JsonPathUtil.java +++ b/groot-common/src/main/java/com/geedgenetworks/common/utils/JsonPathUtil.java @@ -2,6 +2,8 @@ package com.geedgenetworks.common.utils; import cn.hutool.log.Log; import cn.hutool.log.LogFactory; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONPath; import com.alibaba.fastjson2.JSONReader; @@ -42,4 +44,35 @@ public class JsonPathUtil { } return flattenResult; } + public static Object get(JSONObject jsonObject, String expr) { + Object Result = ""; + try { + Result = jsonObject.getByPath(expr); + } catch (Exception e) { + logger.error( + "The label resolution exception or [expr] analytic expression error" + + e.getMessage()); + } + return Result; + } + public static JSONObject set(JSONObject jsonObject, String expr,Object value) { + try { + JSONPath.set(jsonObject, expr, value); + } catch (Exception e) { + logger.error( + "JSONObject set value exception or [expr] expression error" + + e.getMessage()); + } + return jsonObject; + } + public static JSONObject remove(JSONObject jsonObject, String expr) { + try { + JSONPath.remove(jsonObject, expr); + } catch (Exception e) { + logger.error( + "JSONObject remove value exception or [expr] expression error" + + e.getMessage()); + } + return jsonObject; + } } diff --git a/groot-common/src/main/resources/udf.plugins b/groot-common/src/main/resources/udf.plugins index f5a4c3f..18446c9 100644 --- a/groot-common/src/main/resources/udf.plugins +++ b/groot-common/src/main/resources/udf.plugins @@ -21,4 +21,5 @@ com.geedgenetworks.core.udf.udaf.LongCount com.geedgenetworks.core.udf.udaf.Mean com.geedgenetworks.core.udf.udaf.LastValue com.geedgenetworks.core.udf.udaf.FirstValue -com.geedgenetworks.core.udf.udtf.UnRoll
\ No newline at end of file +com.geedgenetworks.core.udf.udtf.JsonUnroll +com.geedgenetworks.core.udf.udtf.Unroll
\ No newline at end of file |
