java:json:Fastjson将object转为Json时避免出现"$ref"

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38750084/article/details/88079158

我的情况是数据库查询数据,然后各种操作取值(包括多层 for循环),封装json后,返回的json格式的string中含有"$ref",

问题原因是造成了循环引用,解决方式如下:

return JSON.toJSONString(你的json串, SerializerFeature.DisableCircularReferenceDetect);

猜你喜欢

转载自blog.csdn.net/weixin_38750084/article/details/88079158