-
Notifications
You must be signed in to change notification settings - Fork 496
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
[BUG]JSONPath不支持中划线 #2228
Comments
此外,我还找寻了一些JSONPath在线解析的站点,我发现这些站点均支持包含中划线的键: |
JSONObject u = JSON.parseObject("{\"phone-Numbers\": \"XXX\"}");
Map<String, Object> paths = JSONPath.paths(u);
JSONPath.set(u,"$['phone-Numbers']", "ccc"); 换一种写法试试看? |
师傅给出的代码确实没问题,但我有一个疑问: 使用JSONPath.paths();获取的结果:$.phone-Numbers=XXX |
是的,我要修改paths的实现的 |
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.47-SNAPSHOT/ |
没问题了 |
问题描述
JSONPath不支持中划线
环境信息
请填写以下信息:
重现步骤
期待的正确结果
json键”phone-Numbers“的值被正确设置为ccc
相关日志输出
Exception in thread "main" com.alibaba.fastjson2.JSONException: not support -
at com.alibaba.fastjson2.JSONPathParser.parse(JSONPathParser.java:109)
at com.alibaba.fastjson2.JSONPath.of(JSONPath.java:452)
at com.alibaba.fastjson2.JSONPath.set(JSONPath.java:91)
at org.example.demo.main(demo.java:17)
The text was updated successfully, but these errors were encountered: