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

[BUG] fastjson2生成有$ref引用关系的数据序列化到文件后,解析json文件,不能转换为引用的对象,仍然是$ref #2140

Closed
dongxp opened this issue Dec 29, 2023 · 12 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@dongxp
Copy link

dongxp commented Dec 29, 2023

问题: fastjson2 版本2.0.43,读取json文件到jsonobject,生成的jsonobject中引用未处理,仍然是$ref

复现场景:
String jsonString = "{"ProjectAttr":[{"ZYAttr":[{"ProjectAttrID":"4777014153688645650","BidNodeID":1,"AttrValue":"3.0"}]}],"ZYAttr":[{"$ref":"$.ProjectAttr[0].ZYAttr[0]"}]}";
JSONObject doc = JSON.parseObject(jsonString);
image

阅读源码发现,JSONReader.class中:
image
处理引用的代码没地方调用,是遗漏了吗

@dongxp dongxp added the bug Something isn't working label Dec 29, 2023
@wenshao
Copy link
Member

wenshao commented Dec 30, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.45-SNAPSHOT/
问题已修复,请帮2.0.45-SNAPSHOT验证问题是否已经修复,我会尽快发布新版本

@wenshao wenshao added this to the 2.0.45 milestone Dec 30, 2023
@wenshao wenshao added the fixed label Dec 30, 2023
@dongxp
Copy link
Author

dongxp commented Jan 2, 2024

2.0.45-SNAPSHOT验证没问题了,正式版本什么时候发布呢

@wenshao
Copy link
Member

wenshao commented Jan 2, 2024

1月7日之前

@dongxp
Copy link
Author

dongxp commented Jan 5, 2024

请问正式版发布了吗

@wenshao
Copy link
Member

wenshao commented Jan 7, 2024

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

@wenshao wenshao closed this as completed Jan 7, 2024
@longchengli
Copy link

image
image

help help 为啥用了你说的修复的版本试了还是还原不了ref

@dongxp
Copy link
Author

dongxp commented Jan 12, 2024

你确信下你用的是不是2.0.45我试的好着呢

@dongxp
Copy link
Author

dongxp commented Jan 12, 2024

    String ss = "{\"ProjectAttr\":[{\"ZYAttr\":[{\"ProjectAttrID\":\"4777014153688645650\",\"BidNodeID\":1,\"AttrValue\":\"3.0\"}]}],\"ZYAttr\":[{\"$ref\":\"$.ProjectAttr[0].ZYAttr[0]\"}]}";
    Object doc1 = JSONObject.parseObject(ss);

@longchengli
Copy link

    String ss = "{\"ProjectAttr\":[{\"ZYAttr\":[{\"ProjectAttrID\":\"4777014153688645650\",\"BidNodeID\":1,\"AttrValue\":\"3.0\"}]}],\"ZYAttr\":[{\"$ref\":\"$.ProjectAttr[0].ZYAttr[0]\"}]}";
    Object doc1 = JSONObject.parseObject(ss);

image
我看了一下对ref这种处理只在这里被引用了,这个是只在数组里面才处理吗

@longchengli
Copy link

    String ss = "{\"ProjectAttr\":[{\"ZYAttr\":[{\"ProjectAttrID\":\"4777014153688645650\",\"BidNodeID\":1,\"AttrValue\":\"3.0\"}]}],\"ZYAttr\":[{\"$ref\":\"$.ProjectAttr[0].ZYAttr[0]\"}]}";
    Object doc1 = JSONObject.parseObject(ss);

好吧,我试了你的数据,可以正常解析ref回去,是在数组里面可以解析回去,我的数据不在数组里面,这种有办法不。

@dongxp
Copy link
Author

dongxp commented Jan 12, 2024

那估计是bug吧,你给他们提下

@longchengli
Copy link

那估计是bug吧,你给他们提下

好的

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

3 participants