-
Notifications
You must be signed in to change notification settings - Fork 32
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
compacting native types with a type specification in context #545
Comments
First note that your context is a bit tricky:
(you probably know that, but it took me some time to understand it, so it might benefit other rearders of this thread...). This is why the compaction/framing algorithms have a hard time building the "best" compact form for it: it does not "detect" the interactions of these two overridings. There is a actually a workaround: for the second override, instead of |
Yes I agree that the context is a bit tricky (I am dealing with a defined context that people sometimes extend by adding for example a global Regarding the |
The
That's a fair question. I would be tempted to say "yes", but I am not clear about the consequences that such a change would have. |
In the past, we've been reluctant to tie too closely with XSD (other than for conversion of native datatypes like number and boolean). But, this can make things confusing, and even create incorrect serializations. This could get more complicated with formats such as YAML and CBOR which can natively express more datatypes directly, if we choose to allow extensions of the internal representation. |
Just making sure I'm following: This means there's currently no way to take a JSON document (such as an API response) in which an integer value is written as a string and process it with some context (using some combination of JSON-LD 1.1 Processing Algorithms) to produce a JSON-LD document in which the value is a JSON number literal. That is, given Luke Skywalker from SWAPI (abbreviated here): {
"name": "Luke Skywalker",
"height": "172"
} we can't use the JSON-LD 1.1 Processing Algorithms to interpret this with some context, e.g: {
"@vocab": "http://swapi.dev/documentation#",
"height": { "@type": "xsd:integer" }
} to derive: {
"@context": {
"@vocab": "http://swapi.dev/documentation#"
}
"name": "Luke Skywalker",
"height": 172
} Rather, we can only derive the equivalent (with respect to JSON-LD): {
"@context": {
"@vocab": "http://swapi.dev/documentation#"
}
"name": "Luke Skywalker",
"height": { "@value": "172", "@type": "xsd:integer" }
} Do I have that right? In my case, I'd very much like to have the native literal |
This issue comes from digitalbazaar/jsonld.js#466
I have the same issue when trying to round-trip from a framed JSON-LD to RDF and from the produced RDF to a framed JSON-LD.
The xsd:string typing in RDF is omitted as it is considered the default type which is fine.
playground toRDF
When transforming the RDF data to JSON-LD again, we get
And when trying to compact or frame back the data with the same context, we get
playground framing with original context
It seems that the presence of "@type":"xsd:string" prevents the "title" term to be matched and framed.
The same compaction issues appears with the other native types playground xsd:boolean
The text was updated successfully, but these errors were encountered: