We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
fastjson1.x将对象数组序列化后(包含重复引用,故序列化后字符串包含$ref),使用fastjson2反序列化对象,引用对象无法反序列化
如何操作可以重现该问题:
1.创建一个包含重复对象的List,使用 com.alibaba.fastjson.JSON#toJSONString方法序列化 2.使用 com.alibaba.fastjson2.JSON#parseArray,进行反序列化 3.出现反序列化后的list,不包含重复对象
public class Fastjson2Test { @Getter @Setter public static class Bean { private double a; private double b; private double c; } public static void main(String[] args) { // 序列化 Bean bean = new Bean(); bean.setA(1.0); bean.setB(2.0); bean.setC(3.0); List<Bean> beanList = new ArrayList<>(); beanList.add(bean); beanList.add(bean); // jsonStr1="[{\"a\":1.0,\"b\":2.0,\"c\":3.0},{\"$ref\":\"$[0]\"}]" String json1 = com.alibaba.fastjson.JSON.toJSONString(beanList); // 反序列化,json2Bean数组无法还原为beanList List<Bean> json2Bean = com.alibaba.fastjson2.JSON.parseArray(json1, Bean.class, com.alibaba.fastjson2.JSONReader.Feature.SupportSmartMatch); // 结果为[{"a":1.0,"b":2.0,"c":3.0},{"a":0.0,"b":0.0,"c":0.0}] com.alibaba.fastjson2.JSON.toJSONString(json2Bean); } }
对您期望发生的结果进行清晰简洁的描述。 json2Bean数组可以还原为beanList,数组内容一致
The text was updated successfully, but these errors were encountered:
fix parseArray reference incorrect, for issue #3436
7abc631
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.58-SNAPSHOT/ 问题已修复,请帮忙用2.0.58-SNAPSHOT版本验证,2.0.58版本预计在5月初发布。
Sorry, something went wrong.
No branches or pull requests
问题描述
fastjson1.x将对象数组序列化后(包含重复引用,故序列化后字符串包含$ref),使用fastjson2反序列化对象,引用对象无法反序列化
环境信息
重现步骤
如何操作可以重现该问题:
1.创建一个包含重复对象的List,使用 com.alibaba.fastjson.JSON#toJSONString方法序列化
2.使用 com.alibaba.fastjson2.JSON#parseArray,进行反序列化
3.出现反序列化后的list,不包含重复对象
期待的正确结果
对您期望发生的结果进行清晰简洁的描述。
json2Bean数组可以还原为beanList,数组内容一致
The text was updated successfully, but these errors were encountered: