-
-
Notifications
You must be signed in to change notification settings - Fork 374
Description
Describe the inspiration for your proposal
I've read through the spec, but am not a previous participant in the json or json schema spec creation process. I have participated, however, in open source spec creation and implementation.
It's becoming common now to use json+schema as the serialization format for client-server protocols. For example, the Model Context Protocol.
When serializing an object graph with references, the default serialization strategy for most existing libraries is to serialize multiple copies (by value) of any references.
For object graphs (e.g. trees), however, this results in multiple copies of the object being serialized to the stream...e.g.:
TreeNode has field 'parent' which is reference to TreeNode definition (recursive) and several other properties that are not references (e.g. type string).
A.parent is null
B.parent -> A
C.parent -> A
D.parent -> A
etc.
If B, C, and D are serialized to a stream, by default there will be multiple (3) copies of A on the stream. When there is only 1 needed for deserialization and validation.
Several libraries have a mechanism to deal with this...e.g. @JsonIdentityInfo for Jackson, Another is JavaScript Object Graph. I expect there are others and I'm just not aware of them.
These 'dynamic object identity' implementations mostly differ in the name and type of the dynamically added object identity. This variation makes it more difficult to support a multi-language protocol (like MCP).
Is there something in the existing schema spec currently or planned that would allow cross lib/cross language interoperability for serializing object graphs efficiently? If not, would a proposal be desired?
Describe the proposal
TBD
Describe alternatives you've considered
TBD
Additional context
TBD