1.适配TSG 23.07及以上功能,添加数据传输统计指标,并输出至pushgateway。(GAL-409)
2.原URL参数domain从http_domain字段取值,更新为从common_server_domain字段取值。(GAL-410)
This commit is contained in:
45
src/main/java/com/zdjizhi/tools/json/JsonPathUtil.java
Normal file
45
src/main/java/com/zdjizhi/tools/json/JsonPathUtil.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.zdjizhi.tools.json;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.alibaba.fastjson2.JSONPath;
|
||||
import com.alibaba.fastjson2.JSONReader;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author qidaijie
|
||||
* @Package com.zdjizhi.tools.json
|
||||
* @Description:
|
||||
* @date 2023/5/1917:51
|
||||
*/
|
||||
public class JsonPathUtil {
|
||||
private static final Log logger = LogFactory.get();
|
||||
|
||||
private static Map<String, JSONPath> jsonPathMap = new ConcurrentHashMap<>(16);
|
||||
|
||||
/**
|
||||
* 根据表达式使用JsonPath解析数据
|
||||
*
|
||||
* @param message json
|
||||
* @param expr 解析表达式
|
||||
* @return 解析结果
|
||||
*/
|
||||
public static Object analysis(String message, String expr) {
|
||||
Object flattenResult = "";
|
||||
try {
|
||||
JSONReader parser = JSONReader.of(message);
|
||||
if (jsonPathMap.containsKey(expr)) {
|
||||
flattenResult = jsonPathMap.get(expr).extract(parser);
|
||||
} else {
|
||||
JSONPath jsonPath = JSONPath.of(expr);
|
||||
jsonPathMap.put(expr, jsonPath);
|
||||
flattenResult = jsonPath.extract(parser);
|
||||
}
|
||||
} catch (ClassCastException | ArrayIndexOutOfBoundsException e) {
|
||||
logger.error("The label resolution exception or [expr] analytic expression error" + e.getMessage());
|
||||
}
|
||||
return flattenResult;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user