例子
meta: {$ref: "$.data[1].children[0].meta"}
出现这种问题都由于循环引用造成的
循环引用:当一个对象包含另一个对象时,fastjson就会把该对象解析成引用。
解决办法
禁止循环引用:使用fastjson的JSONObject.toJSONString(meta, SerializerFeature.DisableCircularReferenceDetect);
在最终返回的数据的时候可以使用该方法
Map<String, Object> map = new HashMap<>();
Map<String, Object> meta = new HashMap<>();
meta.put("title", "value值");
// 解决办法
String metaStr = JSONObject.toJSONString(meta, SerializerFeature.DisableCircularReferenceDetect);
map.put("meta", JSONObject.parseObject(metaStr));