-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON Array of length 1 gets compacted into non array #509
Comments
Reference to relevant part of the JSON-LD spec https://www.w3.org/TR/json-ld11/#json-literals
|
Ah, I am seeing from this test https://w3c.github.io/json-ld-api/tests/compact-manifest#tjs07 that you have to add That seems like a requirement that is not stated in the spec, and in fact contradicts the spec's notion that JSON literals should not be transformed by the processor in any way. Any one have insight on why this is? |
This might be a good issue to bring the spec as this is just a particular implementation of it. You can do so over here: |
The spec and test coverage of this area is poor. I think your example should by default output the JSON array: There are complications here too. If multiple JSON values are compacted, it would be fine if I'm working up some tests for the WG to look at and clarify how this should work, and jsonld.js fixes will follow. |
Yes, the intersection of I'm sure there are some unexplored corner-cases here. |
Thanks @gkellogg and @davidlehn. I look forward to seeing those tests and their reception in the WG. It sounds to me like |
Creating more special magic for Feel free to raise an issue at https://github.com/w3c/json-ld-api, but I don't see that making the cut for the next version. |
Issue: w3c/json-ld-api#560 |
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:
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:
The text was updated successfully, but these errors were encountered: