- From: Stian Soiland-Reyes <soiland-reyes@cs.manchester.ac.uk>
- Date: Fri, 30 Jan 2015 22:09:34 +0000
- To: Tom De Nies <tom.denies@ugent.be>
- Cc: public-rdf-comments <public-rdf-comments@w3.org>
- Message-ID: <CAPRnXt=jrT9rOKd0ircJUwNnbCyi6kLTitA4a6weuaZtKzeP4Q@mail.gmail.com>
So I guess you are not at liberty to sneak in an additional @id in the JSON documents? Within a document you can have multiple @context at different levels and have different mappings for "id". But if you apply the context externally (e.g. with the Link header), and don't have any explicit @context further in, then a "id" would need to map to the same property for the whole document. http://www.w3.org/TR/json-ld/#interpreting-json-as-json-ld Now, "id" to a uuid sounds like it probably should be a URI and not a string. You are allowed to set @base in such a context, as the Link @context is inserted directly into the top-level object. Therefore, if you are not using relative URI / IRI references in the rest of the document, you could simply link to : (apologies for not syntactically correctness as I'm on my phone) { @context: { @base: http://example.com/objects/ id: @id } } Now this means you have to drop your example:id property and parse those URIs instead if you need to get back to the uuid. You might be able to set the base to "urn:uuid:" if you don't want a hostname. Personally I prefer to map such UUID to a http namespace, even If I might not have anything to serve there today. On the other side you get rid of lots of blank nodes! ;-) If you are only using the uuid for linking from other places, e.g.: { parent: 74747473-3737-474737373 } ..then simply define "parent" as @type: @id in the context and they are linked semantically, both would end up talking about < http://example.com/objects/ 74747473-3737-474737373> the resource rather than 74747473-3737-474737373 the literal. This makes nicer queries. Another alternative is to keep "id" as the pure literal and use an OWL ontology to define it as uniquely identifying the object with owl:hasKey to your example:id datatype property. http://www.w3.org/TR/owl2-syntax/#Keys Now you will ONLY have blank nodes. Most pragmatists prefer to not require OWL reasoning and want to avoid blank nodes.. On 30 Jan 2015 16:38, "Tom De Nies" <tom.denies@ugent.be> wrote: > Hello RDF team, > > this question is mainly directed towards the JSON-LD guys. > > I'm in the situation where I want to create an easy way to convert an > existing JSON model (which I can't edit) to JSON-LD. > Obviously, I'm using an external context document for that, so all one > needs to do to convert their JSON to -LD is to add 1 @context property. > > However, there are some duplicate terms in this model, and unfortunately, > they refer to different things. > For example, there is the term "id". When it occurs anywhere in the > document, its property should be http://example.org/id, and its value > should be a UUID (thus, the @type should be a xsd:string). When it occurs > inside an "object" however, it should be the subject of the corresponding > triple. > > So let's consider an example: > > { > "id" : "123.456.789", > "object" : { > "id" : "http://example.org/myObject" > } > } > > In N3, this should become something like this: > > [] <http://example.org/id> "123.456.789"; > <http://example.org/object> <http://example.org/myObject> . > <http://example.org/myObject> a <http://example.org/Object> . > > How do I model this correctly in JSON-LD? > > Basically, I would like to put something in my context that resembles this: > > > { > "id" : { > "@id" : "http://example.org/id", > "@type" : "xsd:string" > }, > "object" : { > "@id" : "http://example.org/object", > "@type" : "@id" > }, > "object.id" : "@id" > } > > Right now all I can see as a solution is to force the developers to add > the following to every object in their JSON: > "@context" : { > "id" : "@id" > }, > Which would be quite a nuisance compared to just specifying 1 external > context... > Am I missing something? > > Thanks in advance! > > Regards, > Tom > Tom De Nies > Researcher Semantic Web > Ghent University - iMinds > Faculty of Engineering and Architecture > Department of Electronics and Information Systems - Multimedia Lab > Gaston Crommenlaan 8 bus 201, B-9050 Ledeberg-Ghent, Belgium > > e: tom.denies@ugent.be > > URL: http://multimedialab.elis.ugent.be > >
Received on Friday, 30 January 2015 22:10:06 UTC