Every complex object that occurs in BusinessData will get a generated ID which has a prefix of "$Ref-" followed by an increasing integer.
This generated ID is used to store references to other objects in the same BusinessData without duplicating the JSON tree. It guarantees that stored objects will not only be equal after de-serialization, but also of same instance (if they we're at serialization time).
If an object is referenced multiple times within your BusinessData object tree, the first occurence of the object will be stored fully with an @id field. Any later reference will be stored with a simple back reference by using the "$Ref-X".
The following example demonstrates that. My java object tree is a class with has a CEO and CTO field. And these objects are also reference in an List within the "members" field.
Java Object Tree:
Persons persons = new Persons();
persons.members = new ArrayList<>();
V1 rew = new Persons.V1();
rew.firstName = "Reguel";
rew.lastName = "Wermelinger";
persons.members.add(rew);
V1 pes = new Persons.V1();
pes.firstName = "Peter";
pes.lastName = "Stöckli";
persons.members.add(pes);
persons.ceo = rew;
persons.cto = pes;
Serialized JSON:
{
"@id" : "$Ref-0",
"ceo" : {
"@id" : "$Ref-1",
"firstName" : "Reguel",
"lastName" : "Wermelinger",
"street" : null,
"zip" : null,
"city" : null
},
"cto" : {
"@id" : "$Ref-2",
"firstName" : "Peter",
"lastName" : "Stöckli",
"street" : null,
"zip" : null,
"city" : null
},
"members" : [ "$Ref-1", "$Ref-2" ]
}