Re: [JSON] Clarification on JSON-LD

Hey Manu,

On Mar 10, 2011, at 17:47 , Manu Sporny wrote:

> On 03/10/11 09:05, Ivan Herman wrote:
>> I try to familiarize with the different JSON inputs. Looking at
>> JSON-LD, two questions:
>> 
>> Is it correct that
>> 
>> { "foaf:name" : "Ivan" }
>> 
>> translates into
>> 
>> [ foaf:name : "Ivan" ]
> 
> Yes. I'm not great with TURTLE, so for the avoidance of doubt, the above
> is the same as this:
> 
> @prefix foaf: <http://xmlns.com/0.1/foaf/> .
> _:bnode1 foaf:name "Ivan" .


Yes, this is the same.


> 
>> ie, that if I do not have the "@" there, then it is considered to be
>> a blank node in RDF terms?
> 
> Correct.
> 
>> Also, is it so that I can say
>> 
>> { "ex:prop : { "foaf:name" : "Ivan" } }
>> 
>> meaning
>> 
>> [ ex:prop [ foaf:name "Ivan" ] ]
>> 
>> ie, the subject can be a complete JSON object?
> 
> Yes. However, I'm going to be pedantic here: In JSON-LD, the "value" of
> the JSON key-value pair can be an associative array. An associative
> array in JSON-LD can be thought of as a self-contained graph.

Hm. We may have issues here in understanding or in the terms we use. See below

> When it is
> in the "value" position, the current predicate is linked to the
> self-contained graph. That is, this:
> 
> { "ex:prop" : { "foaf:name" : "Ivan" } }
> 
> would give you this:
> 
> @prefix foaf: <http://xmlns.com/0.1/foaf/> .
> _:bnode1 ex:prop _:bnode2 .
> _:bnode2 foaf:name "Ivan" .
> 

But this is not what you wrote above. The turtle code that you gave above simply means that the object of the first triple is bnode, and the latter is also a subject of another triple (and yes, the turtle you gave is the same as what I gave. There is 'graph' here. To give a slightly more elaborate example, and using URI-s, the following:

{ 
  "@" : "<lala>" ,
  "ex:prop : {
      "@" : "<bla>",
      "ex:a" : "Ivan" ,
      "ex:b" : "Manu"
  }
}

should translate into

<lala> ex:prop <bla> .
<bla> ex:a "Ivan" ,
      ex:b "Manu" .

_which is perfectly consistent and fine_, but there is _no_ notion of a self contained graph here!

The 'model' that I have is:

- { .... } provides a set of triples with a common subject
- that subject is either a new bnode (like the [] construction in Turtle) or an explicit URI/bnode if the "@" key is used
- that common subject may appear as the object for a property if this is where {} is used.

Which also means that the following:

{ 
  "@" : {
           "ex:a" : "Manu"
        },
  "ex:b" : "Ivan" 
}

crazily enough, translates into

_:x ex:a "Manu" .  <- that is the translation of the internal object
_:x ex:b "Ivan" .  <- that is the translation of the outer object

If your intention was (which I believe it was) to have some sort of a 'graph literal' here, I think that becomes linguistically inconsistent!

Ivan




> -- manu
> 
> -- 
> Manu Sporny (skype: msporny, twitter: manusporny)
> President/CEO - Digital Bazaar, Inc.
> blog: Payment Standards and Competition
> http://digitalbazaar.com/2011/02/28/payment-standards/
> 


----
Ivan Herman, W3C Semantic Web Activity Lead
Home: http://www.w3.org/People/Ivan/
mobile: +31-641044153
PGP Key: http://www.ivan-herman.net/pgpkey.html
FOAF: http://www.ivan-herman.net/foaf.rdf

Received on Friday, 11 March 2011 08:18:21 UTC