- From: Jindřich Mynarz <mynarzjindrich@gmail.com>
- Date: Sat, 3 Aug 2013 11:45:52 +0200
- To: Gregg Kellogg <gregg@greggkellogg.com>
- Cc: public-linked-json@w3.org
Hi Gregg, thanks for an excellent answer providing exactly the information I needed and the pointers I'll definitely investigate. Best, Jindrich -- Jindrich Mynarz http://mynarz.net/#jindrich On Fri, Aug 2, 2013 at 10:06 PM, Gregg Kellogg <gregg@greggkellogg.com> wrote: > On Aug 2, 2013, at 12:04 PM, Jindřich Mynarz <mynarzjindrich@gmail.com> wrote: > >> Hi, >> >> I'm just starting to use JSON-LD and I've discovered a few points I >> would like to have clarified. Manu Sporny recommended me to ask here, >> so I'm following his advice. I'd be grateful if someone on this list >> would be able to provide me with advice on these points. >> >> Having read through the JSON-LD specification and search the internets >> without success I want to ask about expressivity of JSON-LD @context >> for transforming existing plain JSON so that it can be interpreted as >> JSON-LD [2]. >> >> Let's assume I have the following plain JSON that I want to enrich >> with @context: >> >> { >> "productName" : "Chunky bacon", >> "price" : 3, >> "currency" : "EUR" >> } >> >> Say, I want to map that JSON to JSON-LD using the GoodRelations >> vocabulary (gr:) [3]. I can start with mapping productName property to >> gr:name: >> >> { >> "@context": { >> "gr" : "http://purl.org/goodrelations/v1#", >> "productName" : "gr:name" >> } >> } >> >> Proceeding with the mapping raises several questions. >> >> 1. What if I want to set the rdf:type (i.e. JSON-LD's @type) of the >> object to gr:Offering? I want to do it in @contextwithout changing the >> original plain JSON. Is it possible? > > No, the context can define terms and type mappings, but not insert data. Inferring a type based on the properties of a predicate is something you could do with an RDFS reasoner. So, it would be possible to create the data, turn it into RDF triples, reason, and then turn the RDF back into JSON-LD, which could then include the type of the referenced object. > > Another possibility would be to use JSON-LD-Macros [5], which might be able to do something like this. This could also be done through framing [6], where the frame would include the type of the object (I think). > >> 2. I want to map the price and currency properties to become >> properties of a new object (of {"@type" : "gr:PriceSpecification"}). >> How do I introduce an object property (gr:hasPriceSpecification) that >> will have a new blank node as its object, which will contain the two >> properties mapped to gr:hasCurrencyValue and gr:hasCurrency (again, >> without touching the original JSON)? The output I want to achieve >> should look like (in RDF/Turtle): >> >> @prefix gr: <http://purl.org/goodrelations/v1#> . >> >> [] a gr:Offering ; >> gr:name "Chunky bacon" ; >> gr:hasPriceSpecification [ >> a gr:PriceSpecification ; >> gr:hasCurrencyValue 3 ; >> gr:hasCurrency "EUR" >> ] . > > That requires more manipulation, since you have properties for both the subject and object in the same JSON object. You'd either need to have them separated into different objects in the first place, something like the following: > > { > "productName" : "Chunky bacon", > "priceSpec": { > "price" : 3, > "currency" : "EUR" > } > } > > Otherwise, I'd look at JSON-LD Macros to see if there's more you can do there. > >> 3. Is it possible, similarly to the first question, to use @context to >> add "constant" data, i.e. data that is present in @context and will be >> added to JSON-LD during its expansion? For example, is it feasible to >> add fixed {"gr:valueAddedTaxIncluded" : true} property-value pair to >> each gr:PriceSpecification? Again, without changing the original JSON. > > No, @context doesn't add data. You could envision a future update that might do the things you suggest, but it's not part of JSON-LD 1.0. > >> I've previously asked the question at answers.semanticweb.com [4], so >> you can provide answers there as well. > > Will do. > > Gregg > > [5] https://github.com/antoniogarrote/json-ld-macros > [6] http://json-ld.org/spec/latest/json-ld-framing/ > >> Best, >> >> Jindrich >> >> [1] https://twitter.com/manusporny/status/363359212161998848 >> [2] http://www.w3.org/TR/json-ld/#interpreting-json-as-json-ld >> [3] http://www.heppnetz.de/ontologies/goodrelations/v1.html >> [4] http://answers.semanticweb.com/questions/23894/expressivity-of-json-ld-context-for-mapping-plain-json-without-changing-it > >> -- >> Jindrich Mynarz >> http://mynarz.net/#jindrich >> >
Received on Saturday, 3 August 2013 09:46:39 UTC