-
Notifications
You must be signed in to change notification settings - Fork 170
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
Describe JSON-LD with WebIDL - How to handle @ tags #541
Comments
So I think the problem here is you’re using WebIDL to describe the JSON format and not the actual JS APIs that are going to wrap it up. You probably want to use JSON schema for this and/or follow whatwg/infra#159. |
Agreed, Web IDL is not meant to describe JSON and is not in general a good tool for the job. |
Also agree. We screwed up web manifest trying to describe it as WebIDL. Please avoid making similar mistakes. |
I also suggested using a method, for instance something like However, it was suggested that if we can't get WebIDL to support the use case, then just simply leave them out of the WebIDL descriptions and use prose in the spec describing them (like with internal slots), since ECMAScript allows using |
Realistically, you have a few options, if these are meant to be objects implemented by the browser (and hence interfaced with via Web IDL):
What you probably can't get browsers to implement is having an object that has a bunch of stuff defined in IDL and oh, some other properties that are not defined in IDL. If these are not objects meant to be implemented by browsers, then I'm not sure why one would use Web IDL for defining them, necessarily. |
Thanks @bzbarsky, makes sense. Either 1. or 2. would work for me. We are using maplike also elsewhere in the API. Need to check on the named getter semantics. Although the Web of Things mainly targets runtimes for (server) Thing implementations, the future possibility of implementing client, or even server Things in browsers is in scope, hence we strive to be able to describe Thing APIs with WebIDL. |
Note that you can also have something like this: interface Thing {
object getJSONLD();
}; Where |
Probably just |
Hi WebIDL community,
we in the WoT working group and specifically the task force around scripting are working on a document (current version) that tries to describe the functionality of a WoT thing description (TD) that is based on JSON-LD. Moreover, based on this TD JSON-LD document scripting acts as a wrapper and adds further functionality to manipulate the content.
JSON-LD documents tend to have lots of
@
tagnames. For example a TD snippet:These
@
tags cause issues in WebIDL (as in any programming language) given that those names are not valid identifiers.Moreover, a naive solutions to this issue like removing/replacing the
@
prefix all together is also not very usable/practical given that@type
there might be alsotype
fieldsHence, I was wondering whether you, as the WebIDL experts, have additional proposals or another way of tackle this issue. Have you (or others?) run into the same issue with JSON-LD and WebIDL?
How could we describe the content of a JSON-LD document with WebIDL?
Thanks a lot for any insight or tip!
The text was updated successfully, but these errors were encountered: