-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[BUG]JSONPath 解析嵌套数组异常 #1070
Comments
wenshao
added a commit
that referenced
this issue
Jan 12, 2023
补充一些相关的测试用例,帮助复现 String raw = "[[{\"a\":1},{\"a\":2}],[{\"a\":3}]]";
Assert.assertEquals("[{\"a\":1},{\"a\":2},{\"a\":3}]",
((JSONArray) JSONPath.extract(raw, "$[*][*]")).toJSONString());
Assert.assertEquals("[{\"a\":3}]",
((JSONArray) JSONPath.extract(raw, "$[1][*]")).toJSONString());
Assert.assertEquals("{\"a\":1}", ((JSONObject) JSONPath.extract(raw, "$[0][0]")).toJSONString());
Assert.assertEquals("[1,2,3]", ((JSONArray) JSONPath.extract(raw, "$[*][*].a")).toJSONString()); |
@wenshao 多谢,我测试了下,目前上述的 case 都已经通过了,我们已经在生产环境替代了 json-path。 目前还有一个 case 有点诡异,不知道是 by design 的还是 bug? // 测试不通过,返回的是嵌套数据 "[[[{\"a\":1},{\"a\":2}],[{\"a\":3}]]]";
String raw = "[[{\"a\":1},{\"a\":2}],[{\"a\":3}]]";
Assert.assertEquals("[[{\"a\":1},{\"a\":2}],[{\"a\":3}]]",
((JSONArray) JSONPath.extract(raw, "$")).toJSONString());
// 测试通过
Assert.assertEquals("[[{\"a\":1},{\"a\":2}],[{\"a\":3}]]";,
((JSONArray) JSONPath.extract(raw, "$[*]")).toJSONString()); 貌似用 fastjson2 |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
问题描述
JSONPath 解析嵌套数组异常,例如
$[*][*]
环境信息
请填写以下信息:
重现步骤
期待的正确结果
嵌套数组解析正常
相关日志输出
请复制并粘贴任何相关的日志输出。
附加信息
如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。
The text was updated successfully, but these errors were encountered: