-
Notifications
You must be signed in to change notification settings - Fork 23
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
Specify a node type when interpreting JSON as JSON-LD (was: use of "@type" in "@context") #386
Comments
Type coercion can not be used to automatically add an
|
The use case is the following: I need to provide a framework to create jsonld annotated payloads out of existing json APIs payloads. Is it possible to register and publish an extension keyword to json-ld (eg. a cc: @ccattuto |
There is no such registration mechanism, although the API spec does have some processing considerations for things that look like keywords. In the past, when people were trying to use |
I used Framing to transform RDF in plain json objects: I'll check if there's a way to use it for transforming json in RDF |
It seems this is a recurring issue:
Still in my perspective, this makes quite complex adding metadata to existing APIs without
->
@gkellogg While I read the threads, it's not clear to me how framing can help, since:
|
Exactly. And this choice is not a matter of security, but more of bounding the complexity. JSON-LD does not aim to allow you to express any arbitrary JSON to RDF transformation.
That's an interesting way to look at it... but the stance taken by JSON-LD is that it is just another arc. Another possible way to solve your problem would be to rely on RDFS and some form of (light) inference. What you want to encode in your context looks very much like an
|
@pchampin thanks for your reply.
How is it possible to express As an example, this patched API editor can transform a JSON payload to RDF using the information provided by a |
To rephrase my proposal: you do not explicitly add the Mind you: I perfectly understand that this option may not work in all contexts (some users will not have the ability to perform any kind of inference, not even as light as RDFS). But I think it is worth putting in on the table. |
@pchampin now it is clear :) Actually we provide something like that in the patched editor above. In some cases, a given field can have multiple possible classes. Other times, we would like a schema designer to start from a rdf:type and identify properties starting from there. iiuc this is something that's not going to be supported in json-ld. Since a preliminary goal is to attach a semantic context for OAS3-described APIs Next, I'll identify a way to describe in OAS3 documents the remaining information Thanks again for your time Pierre-Antoine. @gkellogg if this is a definitive wont-fix, please feel free to close. |
@ioggstream wrote:
Correct, however, what we recommend that people do to support the sort of use case you're describing is to write a pre-processor or post-processor. The feature you're describing is a fairly simple function written in most languages that just searches the document structure for specific keywords (either before or after JSON-LD processing) and injects new nodes into the graph. So, you could wait around for the JSON-LD WG to decide to implement, standardize, test, and publish a new standard... OR, you could just implement it in 10 lines of code or so. :) My suggestion is you write some code to do this, point to the code, and perhaps others will find your code useful as a JSON-LD pre/post-processor. |
we're working on a national API catalogue, and we want to add the ability for API providers to attach semantic information to the existing json schema documents. The goal is to define a syntax allowing to describe all relevant information to interpret json as json-ld for existing APIs, so before writing code, the issue for me is how to describe the nodes to be added. I wrote a little gdoc with the problem statement... |
Thanks @ioggstream for the doc. I'm also looking into this in the context of a community with a series of JSON schemas (often competing in scope due to different histories) and OpenAPI usage. I have looked at the requirements and logic here Domain model interoperability - a work in progress - this thread had been helpful in confirming my understanding of the scope of json-ld-framing at least - thanks, I see lots of statements about "you will need a parser" etc - but I havent seen any articulation of the overall architecture being discussed - only bottom-up analyses of options and challenges. The default architecture of the web is client->server with some negotiation -> resources with links to other resources. I was excited when i found this.. https://www.w3.org/standards/webarch/principles ... but it didnt last long :-( |
Interesting! Could you share more details about your goals (e.g. examples without sensitive information ...)?
The idea of the document is to provide a syntax to support an architecture based on REST APIs.
Thanks for the link, I added some content (mainly clarification stuff). |
For an overview of current state, which is a transition from XML based RPC style services to OpenAPI see https://ogcapi.ogc.org/ |
Was looking into JSON-LD as a possible mapping/transformation mechanism but trivial issues like this make it clear that it's not powerful enough. |
JSON-LD can't be everything to everyone, as @pchampin said earlier in this thread, all languages make decisions to bound complexity. Another way to put it is: JSON-LD is already complex enough w/o adding features like this to meet use cases that aren't (yet?) harming JSON-LDs adoption. On the contrary, the latest numbers from common crawl seem to indicate that the JSON-LD feature set is enough to see its usage across hundreds of millions of websites. That said, I do think JSON-LD currently has features that add little value and, ideally, we'd remove those features. For example, property based indexing, node identifier indexing, and node type indexing have not seen significant usage. The feature being discussed in this thread could fall into the same category, but I can also see why it would be useful. The question is, will it be useful enough to define it? We all know how difficult to impossible it is to remove features from languages once they're there. With JSON-LD 1.0, we had to guess at a fair amount of this "is it a useful feature" stuff (we didn't have usage data when we were doing v1.0), and in hindsight, it's now clear that we guessed wrong on a small subset of features (because they're not being used like we thought they were going to be used). That led to code/processor complexity that could be optimized out (if the group can muster the momentum to do so -- always a difficult ask of any group to CUT features that have been deployed). JSON-LD v2.0 should do this, though I expect I'm in the minority in suggesting that as a course of action for JSON-LD v2.0. IOW, the way to convince the group that a new feature is required is to provide some code for the feature you want, get a community together that uses/depends on the code, and then use that as a driver for the usefulness of a feature. We may want to take a polyfill approach to all future JSON-LD feature requests, and we might want to see if standardizing hooks into JSON-LD processors that enable @ioggstream to do what he's suggesting w/o impacting the core standard would lead to better outcomes. The process would be something like:
That approach feels more sustainable than trying to convince the WG to add a feature when there are only a handful of examples of the feature being useful to a subset of the community. |
cc: @mfortini FYI |
A related problem: if |
Question
It's not clear to me if it's legitimate to use
@type
in@context
instead of in the JSON object, eg.since the jsonld playground renders this as
while I expect
Note
changing the payload to
results in
meaning that in some way the "City" type is processed in some way.
The text was updated successfully, but these errors were encountered: