当前位置:网站首页>03 fastjason solves circular references
03 fastjason solves circular references
2022-07-03 09:59:00 【look-word】
FastJson Solve circular references
The reasons causing In the object to be converted There are two references with the same address
Code display :
public static void main(String[] args) {
ArrayList<Object> list = new ArrayList<>();
Object o = new Object();
list.add(o);
list.add(o);
// Output length
System.out.println(list.size());
// convert to json Result of character
System.out.println(JSONObject.toJSONString(list));
}
The results show that , Converted json String is not what we want , The general reason for the problem is fastjson During the conversion , It is found that there is already a reference to this location , So the later one points to the previous reference , So how to solve this problem ?
// Solve circular references
System.out.println(JSONObject.toJSONString(list,SerializerFeature.DisableCircularReferenceDetect));
You can see Now we have successfully solved the problem of circular reference
边栏推荐
- Simple use of MySQL (addition, deletion, modification and query)
- STM32 port multiplexing and remapping
- 2021-01-03
- [keil5 debugging] warning:enumerated type mixed with other type
- el-table X轴方向(横向)滚动条默认滑到右边
- STM32 running lantern experiment - library function version
- JMX、MBean、MXBean、MBeanServer 入门
- 2020-08-23
- 自动装箱与拆箱了解吗?原理是什么?
- Serial communication based on 51 single chip microcomputer
猜你喜欢
对于新入行的同学,如果你完全没有接触单片机,建议51单片机入门
在三线城市、在县城,很难毕业就拿到10K
[CSDN] C1 training problem analysis_ Part II_ Web Foundation
yocto 技术分享第四期:自定义增加软件包支持
2021-10-28
JS foundation - prototype prototype chain and macro task / micro task / event mechanism
Embedded systems are inherently flawed. Compared with the Internet, there are so many holes that it is simply difficult to walk away from
【男保姆式】教你打开第一个微信小程序
UCI and data multiplexing are transmitted on Pusch (Part 4) --small block lengths
没有多少人能够最终把自己的兴趣带到大学毕业上
随机推荐
Project cost management__ Topic of comprehensive calculation
Happy Dragon Boat Festival—— Zongzi written by canvas~~~~~
Do you understand automatic packing and unpacking? What is the principle?
byte alignment
Project cost management__ Cost management technology__ Article 6 prediction
[22 graduation season] I'm a graduate yo~
编程思想比任何都重要,不是比谁多会用几个函数而是比程序的理解
Runtime.getRuntime().gc() 和 Runtime.getRuntime().runFinalization() 的区别
You need to use MySQL in the opening experiment. How can you forget the basic select statement? Remedy is coming~
STM32 external interrupt experiment
Basic knowledge of communication interface
The third paper of information system project manager in soft examination
端午节快乐!—— canvas写的粽子~~~~~
[graduation successful] [1] - tour [Student Management Information System]
内存数据库究竟是如何发挥内存优势的?
uniapp 实现微信小程序全局分享及自定义分享按钮样式
Pymssql controls SQL for Chinese queries
Getting started with JMX, MBean, mxbean, mbeanserver
UCI and data multiplexing are transmitted on Pusch (Part V) -- polar coding
开学实验里要用到mysql,忘记基本的select语句怎么玩啦?补救来啦~