Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONPath 提取数据报错 [BUG] #1965

Closed
lyn-my opened this issue Oct 30, 2023 · 2 comments
Closed

JSONPath 提取数据报错 [BUG] #1965

lyn-my opened this issue Oct 30, 2023 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@lyn-my
Copy link

lyn-my commented Oct 30, 2023

问题描述

使用 fastjson2中jsonpath.eavl 提取数据时会报错

Exception in thread "main" com.alibaba.fastjson2.JSONException: error, offset 48, char :
at com.alibaba.fastjson2.JSONReaderUTF16.skipValue(JSONReaderUTF16.java:4551)
at com.alibaba.fastjson2.JSONPathSegmentIndex.accept(JSONPathSegmentIndex.java:486)
at com.alibaba.fastjson2.JSONPathMulti.extract(JSONPathMulti.java:357)
at com.alibaba.fastjson2.JSONPath.extract(JSONPath.java:56)
at com.alibaba.fastjson2.JSONPath.eval(JSONPath.java:66)
at Test.main(Test.java:24)

环境信息

请填写以下信息:

  • OS信息: [e.g.:win11]
  • JDK信息: [e.g.:Openjdk 1.8.0_312]
  • 版本信息:[e.g.:Fastjson2 2.0.41]

重现步骤

如何操作可以重现该问题:

String temp = "{\n" +
                "  \"code\": \"1003\", \n" +
                "  \"data\": [], \n" +
                "  \"message\": \"code: 1003 ,以【你好】开头的句子的长度不符合要求, 长度限制:3~500,实际长度:2\"\n" +
                "}\n";
 String b1 = (String) JSONPath.eval(temp, "$.data[0][0]");

期待的正确结果

对您期望发生的结果进行清晰简洁的描述。
jsonpath 提取不到,应该输出null

相关日志输出

请复制并粘贴任何相关的日志输出。

附加信息

如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。

@lyn-my lyn-my added the bug Something isn't working label Oct 30, 2023
@wenshao wenshao added this to the 2.0.42 milestone Oct 30, 2023
@wenshao
Copy link
Member

wenshao commented Oct 30, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson/2.0.42-SNAPSHOT/
问题已修复,请帮忙用2.0.42-SNAPSHOT版本验证,正式版本预计在下个周末(11月5日)发布。

@wenshao wenshao added the fixed label Oct 30, 2023
@wenshao
Copy link
Member

wenshao commented Nov 5, 2023

https://github.com/alibaba/fastjson2/releases/tag/2.0.42
问题已修复,请用新版本

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants