In JSON-LD, multiple nested contexts are allowed. They seem to implement a "shadowing" model which should be reasonably simple to replicate. However, I don't think many existing implementations will handle this correctly. So I propose this implementation:
Groundwork:
ContextStack property on TypeMapConverter. Each new JsonLDContext is pushed, and popped when we exit the scope. Private.
Split TypeMap.LDContext into LocalContext and ParentContext. LocalContext is null unless this object has local-only context overrides. In the root object, Parent should point to Local. Create new public getter that returns Local ?? Parent. Do not set Local this except on deserialization!
Serialization:
Write TypeMap.LocalContext, unless its null.
Deserialization:
Peek top of ContextStack and assign it to TypeMap.ParentContext
In JSON-LD, multiple nested contexts are allowed. They seem to implement a "shadowing" model which should be reasonably simple to replicate. However, I don't think many existing implementations will handle this correctly. So I propose this implementation:
Groundwork:
ContextStack
property onTypeMapConverter
. Each newJsonLDContext
is pushed, and popped when we exit the scope. Private.TypeMap.LDContext
intoLocalContext
andParentContext
. LocalContext is null unless this object has local-only context overrides. In the root object, Parent should point to Local. Create new public getter that returnsLocal ?? Parent
. Do not setLocal
this except on deserialization!Serialization:
TypeMap.LocalContext
, unless its null.Deserialization:
ContextStack
and assign it toTypeMap.ParentContext
TypeMap.LocalContext
ContextStack
Open Questions:
JsonLDContext
need aParent
property?Relates to #152