Using JSON-LD @context to map plain JSON without any changes to it

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?

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"
  ] .


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.

I've previously asked the question at answers.semanticweb.com [4], so
you can provide answers there as well.

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 Friday, 2 August 2013 19:05:10 UTC