json-ld.org icon indicating copy to clipboard operation
json-ld.org copied to clipboard

Creating Linked Data from JSON is harder then expected

Open gcarothers opened this issue 13 years ago • 7 comments

The hardest part of creating Linked Data from JSON is assigning URIs to specific parts of the JSON. In examples this is done by adding @id to specific parts of the JSON. In real world JSON there are often already IDs, however these IDs are NOT URIs, some method for turning them into URIs is required. Happily @id combined with @base works. HOWEVER, it only works as long as there is only a single kind of Resource that needs an URI. Some method of assigning URIs to Resources that are nested with, or coincident with the Resources of the other types. See comments for concrete examples.

gcarothers avatar Jun 28 '13 23:06 gcarothers

https://gist.github.com/gcarothers/5888777 is an example JSON file WITH @ids created based on per-existing fields. However the @ids can't be created via the @context, instead https://gist.github.com/gcarothers/5888789 is used to modify the object tree and create contextual URIs for the Resources.

gcarothers avatar Jun 28 '13 23:06 gcarothers

https://gist.github.com/gcarothers/5888533 is an example of trying to create URIs via a @context that works! ... except judges are happily conflated with cases.

gcarothers avatar Jun 28 '13 23:06 gcarothers

The scoped context idea might also be useful in this use case. See #247 and #262. It might let you have a @context with a different @base for particular properties. In theory perhaps even scoped just on property.id so a global @base could be used elsewhere.

davidlehn avatar Jun 28 '13 23:06 davidlehn

This is somewhat related to issue #262, which may be addressed in a future JSON-LD spec, or in a CG extension. Basically, having the ability to define context elements within term definitions can be used to define a single context, but have things vary for nodes under a given property. This might be used, for example, to set a separate @base for values of "judge", for example.

gkellogg avatar Jun 29 '13 01:06 gkellogg

Probably you should have a look at https://github.com/antoniogarrote/json-ld-macros It allows you to declaratively transform JSON to JSON-LD and is quite flexible

lanthaler avatar Jun 30 '13 16:06 lanthaler

Also see #426.

gkellogg avatar Sep 22 '16 17:09 gkellogg

I propose closing this with no change; please 👍 or 👎 to close.

gkellogg avatar Apr 08 '17 21:04 gkellogg