修复JsonPath读取布尔值时出现异常的情况

This commit is contained in:
seagull 2020-09-22 11:35:30 +08:00
parent 03c125961e
commit 1e9b01098a
1 changed files with 8 additions and 1 deletions

View File

@ -404,7 +404,7 @@ public class SubString {
jsonString = (String)result;
}
}else{
jsonString=JsonPath.parse(jsonString).read(expression);
jsonString=JsonPath.parse(jsonString).read(expression).toString();
}
}catch(PathNotFoundException pnfe){
LogUtil.APP.error("通过jsonPath获取JSON字符串指定值出现异常没有找到对应参数路径请确认JSON字符串【{}】表达式是否正确【{}】!",jsonString,expression);
@ -417,4 +417,11 @@ public class SubString {
LogUtil.APP.info("获取JSON字符串指定jsonPath表达式【{}】的值是:{}",expression,jsonString);
return jsonString;
}
public static void main(String[] args) {
String jsonString="{\"Success\":false,\"Text\":\"²Ù×÷ʧ°Ü\"}";
String expression = "$.Success";
jsonString=JsonPath.parse(jsonString).read(expression).toString();
System.out.println(jsonString);
}
}