You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That’s not possible with the current spec. Type coercion in the context only works for values, not for nodes – you have to distinguish between those two.
Currently there’s no way to type a node using just a context. You would need to pre-process the data in order to achieve that. The reason for this design decision is that most of the time, you would end up with invalid data if type coercion would also apply to node objects. I know it doesn’t really solve your problem but does it answer your question?
I am processing plain JSON documents of the form:
{
"propertytype1" : {
"key1" : "value1"
}
}
I want to coerce the "@type" of the nested node value, but I don't see an example in the spec nor can I achieve this in the playground.
My attempt at a context is:
"@context" : {
"propertytype1" : {
"@id" : "http://example.org/propertytype1",
"@type" : "http://example.org/PType1"
},
"@vocab" : "http://example.org/"
}
The compact form generated in the playground is:
{
"http://example.org/propertytype1": {
"http://example.org/key1": "value1"
}
}
What I am trying to achieve is:
{
"http://example.org/propertytype1": {
"@type" : "http://example.org/PType1",
"http://example.org/key1": "value1"
}
}
Is it possible to achieve this, if not how do people generally apply contexts to nested JSON documents to get typed node values?
The text was updated successfully, but these errors were encountered: