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
fastjson.version = 1.2.75
Map<String, String> roles = new HashMap<>(); roles.put("1", "Master"); roles.put("2", "Student"); Person p1 = new Person(roles); Person p2 = new Person(roles);
System.out.println(JSON.toJSONString(p1)); System.out.println(JSON.toJSONString(p2));
{"roles":{"1":"Master","2":"Student"}} {"roles":{"1":"Master","2":"Student"}}
List<Person> oneGroupOfPeople = new LinkedList<>(); oneGroupOfPeople.add(p1); oneGroupOfPeople.add(p2); System.out.println(JSON.toJSONString(oneGroupOfPeople));
[{"roles":{"1":"Master","2":"Student"}},{"roles":{"$ref":"$[0].roles"}}]
Person 类的定义
@Data @AllArgsConstructor @FieldDefaults(level = AccessLevel.PRIVATE) static class Person { Map<String, String> roles; }
The text was updated successfully, but these errors were encountered:
这似乎是有意为之:
Sorry, something went wrong.
貌似是你使用的姿势不对 将 System.out.println(JSON.toJSONString(oneGroupOfPeople)); 替换为下面的代码即可正常输出 System.out.println(JSON.toJSONString(oneGroupOfPeople, SerializerFeature.DisableCircularReferenceDetect));
System.out.println(JSON.toJSONString(oneGroupOfPeople));
System.out.println(JSON.toJSONString(oneGroupOfPeople, SerializerFeature.DisableCircularReferenceDetect));
DisableCircularReferenceDetect
这样就关闭了循环引用检测了
No branches or pull requests
fastjson.version = 1.2.75
[{"roles":{"1":"Master","2":"Student"}},{"roles":{"$ref":"$[0].roles"}}]
Person 类的定义
The text was updated successfully, but these errors were encountered: