Is there a way to influence the serialization process using @JsonIdentityInfo so that it inserts the whole object instead of the id reference?
@Entity
@JsonIdentityInfo(
generator = ObjectIdGenerators.IntSequenceGenerator.class,
property = "linkLabel")
public class LinkLabel implements Serializable {
}
Therefore, instead of referencing "otherObj" with id 1, Jackson must include the entire object.
{
"objects": [{
"id": 1,
"otherObj": [{
"id": 1,
...
}, {
"id": 3,
...
}]
},
"id": 2,
"otherObj": [1] <-- referencing otherObj with id 1
]
}
like here:
{
"objects": [{
"id": 1,
"otherObj": [{
"id": 1,
...
}, {
"id": 3,
...
}]
},
"id": 2,
"otherObj": [{
"id": 1, <-- desired format, whole object
...
}]
]
}
We have bi-directional links, so @JsonManagedReference and @JsonBackReference are not working properly. This behavior is described here ( http://wiki.fasterxml.com/JacksonFeatureObjectIdentity ).
source
share