context reference in flattened json+ld #75
-
I'm hoping to use {
"@context": "https://w3id.org/ro/crate/1.1/context",
"@graph": [
{
"@id": "./",
"identifier": "1234",
"@type": "Dataset",
}
]
} My code looks like this: proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
newDoc := map[string]any{"@type": "http://schema.org/Dataset", "@id": "./"}
val := map[string]any{"@value": "123"}
ld.AddValue(newDoc, "http://schema.org/identifier", val, true, false, false, false)
ctx := map[string]any{
"@context": roContext,
}
flat, err := proc.Flatten(newDoc, ctx, options)
if err != nil {
log.Fatal(err)
}
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
enc.Encode(newDoc)
enc.Encode(flat) I'm noticing that the resulting "@context": { ... } I'd like: "@context": "https://w3id.org/ro/crate/1.1/context", I can manually change the value, but I was wondering if there's a better way. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I need to check the definition of the compaction algorithm to confirm the prescribed behaviour. I think you are right and it should preserve the shape of the given context. If so, we'll fix it. As a side observation, if you pass the context as a URL, the algorithm will be downloading the context definition for every invocation of |
Beta Was this translation helpful? Give feedback.
Thanks for the response - that's helpful!