Weird Compaction Problem · Issue #72 · digitalbazaar/jsonld.js (original) (raw)
Take the expanded input...
{ "http://activitystrea.ms/2.0/actor": [ { "http://activitystrea.ms/2.0/displayName": [ {"@value": "test"} ] } ], "http://activitystrea.ms/2.0/displayName": [ { "@value": "http://www.markus-lanthaler.com/" } ] }
Run jsonld.compact using the following context
{ "@context": { "as": "http://activitystrea.ms/2.0/", "displayName": { "@id": "as:displayName" }, "actor": "as:actor" } }
And it comes out as expected...
{ "@context": { "as": "http://activitystrea.ms/2.0/", "displayName": { "@id": "as:displayName" }, "actor": "as:actor" }, "actor": { "displayName": "test" }, "displayName": "http://www.markus-lanthaler.com/" }
However, compact using the following context...
{ "@context": { "as": "http://activitystrea.ms/2.0/", "displayName": { "@id": "as:displayName", "@container": "@language" }, "actor": "as:actor" } }
We get the following...
{ "@context": { "as": "http://activitystrea.ms/2.0/", "displayName": { "@id": "as:displayName", "@container": "@language" }, "actor": "as:actor" }, "actor": { "as:displayName": "test" }, "as:displayName": "http://www.markus-lanthaler.com/" }
Note that the only difference between the first context and the second is that the second adds "@container": "@language".
In the first result, the output is "displayName", in the second it's "as:displayName".