Closed LucaCerina closed 4 years ago
JSON-LD is intended for working with (most) JSON data by applying a context to the data (externalContext in the API, or through a link header).
Not sure what your data represents, but it could be interpreted as a couple of rows in s spreadsheet. Is order important? If so, then the "sleep" might be defined in a context using "@container": "@list"
.
Typically, as long as the keys all map to an IRI, JSON-LD won't drop any information. The simplest context to apply might be the following:
{
"@context": {
"@vocab": "http://example-vocabulary/",
"sleep": {"@container": "@list"}
}
}
(of course, if order is not significant, then no need for that container setting.)
Merging documents together is another matter, where the node identifier of the containing object becomes key.
But, really, you probably need to better define your use case to get more help.
The playground should be a good resource for experimenting.
Okay, the '@vocab' element was the missing point.
Without that, the expanded output was just "example:sleep": [ {} ]
with no values in the array, but now is working properly.
Thank you
Hello, I am kind of a newbie into JSON-LD, so pardon me if I am asking something trivial. I want to map similar data coming from different JSON responses (non LD, just REST results) and so I want to use expansion and subsequent compaction to uniform them.
One document is like: "sleep" : [ {"value1":87, "value2": "ok"}, {"value1":55, "value2": "no"}, ... ] I am not sure if I need framing @graph or @list/@set to manage this problem. Unfortunately the documentation examples on expansion of non-LD json documents are a bit opaque.
Thanks for the help.