Open
Description
When compacting (or framing with an @context
), any @value
of a node with "@type': "@json"
that is a JSON array of length 1 gets transformed into a non array value equalling the first item in the JSON array.
For example:
const doc = {
"https://example.com/people": {
"@type": "@json",
"@value": [ { "name": "Jim" } ]
}
};
const context = {
"people": {
"@id": "https://example.com/people",
"@type": "@json"
}
};
const compacted = await jsonld.compact(doc, context);
console.log(JSON.stringify(compacted, null, 2));
/* Output:
{
"@context": {
"people": {
"@id": "https://example.com/people",
"@type": "@json"
}
},
"people": {
"name": "Jim"
}
}
*/
Note above that the people
field in the output was transformed from a JSON array to an object equal the the original array's first value.
I would expect this library to preserve the original JSON array.
The output should be:
{
"@context": {
"people": {
"@id": "https://example.com/people",
"@type": "@json"
}
},
"people": [
{ "name": "Jim" }
]
}
Metadata
Metadata
Assignees
Labels
No labels