You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ReadContext rct = JsonPath.parse(JsonUtil.getJsonByFileUtils(rateJsonFilePath));
Object data = rct.read("$.data.items");
log.info("data:{}", data);
Object first = rct.read("$.data.items.first()");
log.info("first:{}", first);
print
02:08:58.437 [main] DEBUG com.jayway.jsonpath.internal.path.CompiledPath - Evaluating path: $['data']['items']
02:08:58.437 [main] INFO com.example.demo.jsontest.JsonTest - data:[{"id":1,"app_local":"ff","tax_rate":10,"basic_rate":15.5,"expected_profit_rate":10,"update_user":"yyyyyy","update_time":1669819482},{"id":1,"app_local":"rr","tax_rate":10,"basic_rate":15.5,"expected_profit_rate":10,"update_user":"wxxxxxx","update_time":1669819482}]
02:08:58.437 [main] DEBUG com.jayway.jsonpath.internal.path.CompiledPath - Evaluating path: $['data']['items'].first()
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:64)
Caused by: com.jayway.jsonpath.InvalidPathException: Function with name: first does not exist.
at com.jayway.jsonpath.internal.function.PathFunctionFactory.newFunction(PathFunctionFactory.java:71)
at com.jayway.jsonpath.internal.path.FunctionPathToken.evaluate(FunctionPathToken.java:38)
at com.jayway.jsonpath.internal.path.PathToken.handleObjectProperty(PathToken.java:90)
at com.jayway.jsonpath.internal.path.PropertyPathToken.evaluate(PropertyPathToken.java:80)
at com.jayway.jsonpath.internal.path.PathToken.handleObjectProperty(PathToken.java:90)
at com.jayway.jsonpath.internal.path.PropertyPathToken.evaluate(PropertyPathToken.java:80)
at com.jayway.jsonpath.internal.path.RootPathToken.evaluate(RootPathToken.java:66)
at com.jayway.jsonpath.internal.path.CompiledPath.evaluate(CompiledPath.java:99)
at com.jayway.jsonpath.internal.path.CompiledPath.evaluate(CompiledPath.java:107)
at com.jayway.jsonpath.JsonPath.read(JsonPath.java:179)
at com.jayway.jsonpath.internal.JsonContext.read(JsonContext.java:88)
at com.jayway.jsonpath.internal.JsonContext.read(JsonContext.java:77)
at com.example.demo.jsontest.JsonTest.main(JsonTest.java:58)
... 5 more
my code
print
the data is:
The text was updated successfully, but these errors were encountered: