Use and effects of @JsonIdentityInfo for recursive json schema definitions #311
scottslewis
started this conversation in
General
Replies: 1 comment 8 replies
-
|
Without knowing full details/intents I could be wrong, but I think use of Also quick note on "in practice": that's clumsy way of saying "this is how Jackson implements it" (but implying other implementations could produce output that is not necessarily ordered this way). |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm a little new to the Jackson API, although very experienced in Java.
I'm working on a proposal for adding Groups to the MCP protocol. The mcp-java-sdk uses Jackson (2.19.something I think).
In the Groups proposal I've suggested introducing a nested Group structure, by adding a 'parent' Group attribute. This provides for arbitrary hierarchy of groups.
With normal serialization/deserialization of json with this schema the Group.parent recursive/nested structure could produce a lot of duplication of groups (for example if the same nested hierarchy of Groups was assigned to multiple Tools).
I've heard that the @JsonIdentityInfo annotation can be used for this situation, to replace all but the first given Group instance with a json reference, so that on deserialization the Group tree structure is reconstituted by clients.
I've read the docs for @JsonIdentityInfo and it says this:
...In practice this is done by serializing the first instance as full object and object identity, and other references to the object as reference values....
My question is: Is adding @JsonIdentityInfo to the Group type...e.g. here all that's necessary to get this 'in practice' behavior? (i.e. serialize to json the first reference to a given Group, and send a json reference for all other references?). Or are there other options required for getting this in practice behavior (and/or changing/customizing that behavior)?
Beta Was this translation helpful? Give feedback.
All reactions