-
Notifications
You must be signed in to change notification settings - Fork 495
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 设置数字key #956
Comments
Map data = new LinkedHashMap<>();
JSONPath.set(data, "$.obj['5']", "设置成功");
assertEquals("{\"obj\":{\"5\":\"设置成功\"}}", JSONObject.toJSONString(data)); 你可以这样用 |
JSONPath.paths 遇到数字key返回的是$.obj.5 能改成 $.obj['5'] 吗 ? 不然不能配套使用 |
可以的,我也打算这样改 |
wenshao
added a commit
that referenced
this issue
Nov 30, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Map data = new LinkedHashMap<>();
JSONPath.set(data, "$.obj.5", "设置成功");
System.out.println(JSONObject.toJSONString(data));
会打印:
{"obj":[null,null,null,null,null,"设置成功"]}
我希望是打印 {"obj":{5:"设置成功"}} obj是对象 不是数组
我用的最新的2.0.19
以前的fastjson1 就是支持数字key的 或者说是字符串为数字的 如key 为"12345"
The text was updated successfully, but these errors were encountered: