Reputation: 1420
I am trying to write a JSON-LD frame that serializes some RDF documents in a consistent way. Currently, the RDF is being parsed out from JSON-LD that is correctly structured and I would like the frame to return it in exactly the same way as it came from; later, I will have disparate sources of RDF documents and want them serialized like this too.
The whole example is here. But I will explain my issue with abbreviations for some details, which can be found on the playground.
There is a Named Node of interest, and three Blank Nodes that are all of the same structure (each is a pwo:Step). Each blank node may point to the Next blank node; the Named node points to all three, as well as its First.
input-document.jsonld
{ "@context": { ... },
"@type": "pwo:Workflow",
"first-step": "_:b0",
"steps": {
"_:b0": { "next-step": "_:b1", ...values },
"_:b1": { "next-step": "_:b2", ...values },
"_:b2": { ...values },
}
}
When I attempt to FRAME this document with the following frame:
{ "@context": { ... },
"@type": "pwo:Workflow"
}
it gets denormalized so that the structure is more like this:
{ "@context": { ... },
"@type": "pwo:Workflow",
"first-step" {
"@id": "_:b1",
"next-step": {
"@id": "_:b2",
"next-step": { ...}
}
},
"steps": {
"_:b1": {},
"_:b2": {},
"_:b3": {}
}
}
As you can see, the steps are each embedded in the first-step
section instead of the steps
section.
I was able to avoid this partially by changing the frame like so:
...
"@type": "pwo:Workflow",
"first-step": {
"@embed": "@never"
}
}
However, it still embeds each subsequent step under the next-step
of the prior step.
How can I make my frame, which is referring at the top level to the pwo:Workflow
object, also specify something like @embed: @never
for the child object properties (next-step)? Mainly I have been unable to figure out the syntax for referring to those nested properties such as next-step
. Things like this give opaque errors about failure to parse jsonld:
...
"@type": "pwo:Workflow",
"first-step": {
"@embed": "@never"
},
"steps": {
"next-step": {
"@embed": "@never"
}
}
}
Upvotes: 1
Views: 102
Reputation: 1420
i have found that the errors I got regarding failure to parse jsonld were corrected when I used the CURIE instead of the json-ld link when specifying the nested object`.
{
...
"first-step": {"@embed": "@never"},
"pwo:hasStep": {
"@embed": "@always",
"next-step": {"@embed": "@never"},
"previous-step": {"@embed": "@never"}
}
}
Upvotes: 0