Search code examples
javajsonspringxstream

JSON NO_REFERENCES


I have just started using JSON... I am using it in my project (Spring). I am making JSON string using XStream... I found in tutorial of XStream that using JSON, we have to set it's mode to NO_REFERENCES. I tried out searching it's reason on various sites, but I didn't find it anywhere... I tried removing it from my code... But that also did not had any effect on my output... So, tell me why we have to set it's mode to NO_REFERENCES?


Solution

  • Because, as the tutorial says, JSON has no mechanism for handling references; duplicates must be explicitly written out. If both foo and bar point to baz, then baz will get written twice; once under foo and once under bar.