Fastjson circular reference


fastjson supports circular references and is turned on by default.

Turn off reference support

When the serialized JSON is transmitted to the browser or other languages, these json parsers do not support circular references , resulting in data loss. You can turn off fastjson's circular reference support. Turning off reference detection can also improve serialization performance.

Global configuration shutdown

  JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.DisableCircularReferenceDetect.getMask();

Non-global shutdown

  JSON.toJSONString(obj, SerializerFeature.DisableCircularReferenceDetect);

SyntaxDescription{"$ref":"$"}Reference root object{"$ref":"@"}Quote yourself{"$ref":".."}Reference the parent object{"$ref":"../.."}Reference the parent object of the parent object{"$ref":"$.members[0].reportTo"}Path-based reference