修复JsonPath读取布尔值时出现异常的情况
This commit is contained in:
parent
03c125961e
commit
1e9b01098a
|
@ -404,7 +404,7 @@ public class SubString {
|
||||||
jsonString = (String)result;
|
jsonString = (String)result;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
jsonString=JsonPath.parse(jsonString).read(expression);
|
jsonString=JsonPath.parse(jsonString).read(expression).toString();
|
||||||
}
|
}
|
||||||
}catch(PathNotFoundException pnfe){
|
}catch(PathNotFoundException pnfe){
|
||||||
LogUtil.APP.error("通过jsonPath获取JSON字符串指定值出现异常,没有找到对应参数路径,请确认JSON字符串【{}】表达式是否正确【{}】!",jsonString,expression);
|
LogUtil.APP.error("通过jsonPath获取JSON字符串指定值出现异常,没有找到对应参数路径,请确认JSON字符串【{}】表达式是否正确【{}】!",jsonString,expression);
|
||||||
|
@ -417,4 +417,11 @@ public class SubString {
|
||||||
LogUtil.APP.info("获取JSON字符串指定jsonPath表达式【{}】的值是:{}",expression,jsonString);
|
LogUtil.APP.info("获取JSON字符串指定jsonPath表达式【{}】的值是:{}",expression,jsonString);
|
||||||
return 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue