I am writing a service that uses Jersey and JAXB. My classes are annotated with @XMLRootElement, @XMLElement, etc. I have a circular dependency between two classes, so I annotated the circular dependent property with @XMLTransient. Therefore, when I call my service, I get xml as the default, which works fine. However, when I try to use JSON, I get duplicate lines, for example:
{"name": "der", "record": [{"" points ": 0," victory ": 0," loss ": 0," ties ": 0," leaders ": {" name ":" der "," record ": [{" points ": 0," victory ": 0," loss ": 0," ties ": 0," leaders ": {" name ":" der "," record ": [ {"points": 0, "wins": 0, "loss": 0, "ties": 0, "full size": {"name": "der", "records": [{"" point ": 0, "wins": 0, "losses": 0, "ties": 0, "leaderboard": {"name": "dere", "... etc.
So it seems that there is a circular dependency problem when I use JSON. I would like the cyclic dependent element to be displayed in the JSON output, as is done in XML (due to @XMLTransient annotation).
Can someone give an idea of how I can achieve this?
Prabhdeep gill
source share