-
Notifications
You must be signed in to change notification settings - Fork 13
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
No standard way to map a JSON predicate to a URI #29
Comments
Whaddayamean? What are JSONLD contexts for? cc @manusporny |
Yeah, this is exactly what JSON-LD contexts are for. 😄 The original thread goes on to include this bit of explanation of intent:
Think the idea was to attempt a "standard" mapping for JSON terms...but that would rather limit the world of open data--i.e. putting all keys into a The simplest way to do this in JSON-LD (though obviously not the most resilient...or even wisest...) would be this: {
"@context": {
"@vocab": "urn:{personal-or-app-namespace}:"
},
"foo": "bar",
"baz": {
"foo": "..."
}
} becomes... _:b0 <urn:{personal-or-app-namespace}:baz> _:b1 .
_:b0 <urn:{personal-or-app-namespace}:foo> "bar" .
_:b1 <urn:{personal-or-app-namespace}:foo> "..." . Or add a proper {
"@context": {
"@vocab": "urn:{personal-or-app-namespace}:"
},
"@id": "http://example.com/#local-json",
"foo": "bar",
"baz": {
"foo": "..."
}
} becomes... <http://example.com/#local-json> <urn:{personal-or-app-namespace}:baz> _:b0 .
<http://example.com/#local-json> <urn:{personal-or-app-namespace}:foo> "bar" .
_:b0 <urn:{personal-or-app-namespace}:foo> "..." . Regardless, this is certainly a solved problem, afaict. |
That's an interesting point, but I don't think it fully solves the problem, because nested predicates having the same name need to map to different URIs, to avoid information loss. In JSON, you can distinguish them by the nesting context, in the tree structure. But that context is lost if you just use a generic
becomes this in RDF:
Note that both the outer and inner instances of JSON property "foo" became urn:TEST:foo. What we need instead is for those instances to map to different URIs, something like this:
This can be done in JSON-LD 1.1 (but not 1.0) using a nested
But AFAIK that would require modifying the JSON, to insert those nested @gkellogg, is that correct, or is there some other way of achieving unique URIs for nested properties that have the same name, without modifying the JSON? |
See Scoped Contexts which is there specifically for cases like this. {
"@context": {
"@vocab": "urn:TEST:",
"baz": {"@context": {"@vocab": "baz/"}}
},
"@id": "http://example.com/#local-json",
"foo": "bar",
"baz": {
"foo": "..."
}
} |
Nice! That does have the minor limitation that it still requires the JSON document to be analyzed in advance -- or its schema already known -- in order to emit a custom |
Additionally, contexts can be provided separately from the JSON either via an HTTP Or, via any JSON-LD API compliant code's
|
"there is a wide proliferation of JSON on the web. Yet (in 2019!) we do not have a standard way for developers, and automated tools, to map a JSON predicate into a URI. I've suggested in the past : foo -> urn:string:foo . But that has yet to gain mind share. Tim has suggested we have an HTTP JSON
ontology."
https://lists.w3.org/Archives/Public/semantic-web/2018Nov/0171.html
The text was updated successfully, but these errors were encountered: