W3C home > Mailing lists > Public > public-rdf-wg@w3.org > April 2011

Re: [JSON] RDF collections and JSON arrays

From: Pierre-Antoine Champin <pierre-antoine.champin@liris.cnrs.fr>
Date: Sat, 02 Apr 2011 16:06:28 +0530
Message-ID: <4D96FC2C.2060005@liris.cnrs.fr>
To: Steve Harris <steve.harris@garlik.com>
CC: RDF Working Group <public-rdf-wg@w3.org>
Catching up quite late on my emails,

I also like Pat's proposal. Another alternative would be to use
"special" JSON keys and make the list an "object", e.g.:

  {
    "rdf:type": "rdf:List",
    "@values": [ v1, v2, v3 ]
  }

This has the benefit of making the list homogeneous to other resources;
furthermore, explicitly stating its type would make it easy to recognize
as a list, triggering the look-up of the "@values" attribute.

  pa


PS: the use of CURIEs as string in my example is an approximation; I'm
not advocating any solution for the URI/CURIE issue here.



On 03/25/2011 10:40 PM, Steve Harris wrote:
> On 2011-03-25, at 13:35, Pat Hayes wrote:
> 
>>
>> On Mar 25, 2011, at 3:33 AM, Steve Harris wrote:
>>
>>> Equally I see using [ ] just to encode multiple object for a single subject and predicate as problematic, consider (in no particular syntax):
>>>
>>> {
>>>  ...
>>>  "http://example.com/alice": {
>>>     "foaf:name": "Alice"
>>>  },
>>>  "http://example.com/bob": {
>>>     "foaf:name": [ "Bob", "Bob Smith" ]
>>>  }
>>> }
>>>
>>> That makes access to the data without a library tricky, as for every "object" you read, you'll need some conditional designed to test if it's an array/vector/list, or a literal value.
>>>
>>> Though it makes the simple case uglier, it would probably be better to always use an array to represent objects, if the aim is to allow access without a library:
>>>
>>> {
>>>  ...
>>>  "http://example.com/alice": {
>>>     "foaf:name": [ "Alice" ]
>>>  },
>>>  "http://example.com/bob": {
>>>     "foaf:name": [ "Bob", "Bob Smith" ]
>>>  }
>>> }
>>>
>>> I'm also not keen on [[ ]] for RDF collections, but don't see a sensible alternative.
>>
>> How about [rdf:Collection [ this that other]]  rather than [[this that other]]. I like having a glaring in-your-face label for this case, one that nobody can possibly confuse with anything else. If we use this 'style' consistently, might that make code writing somewhat easier? OK, there will have to be some conditionals to test the first element, but is that so bad?
> 
> Given that RDF Collections are pretty rare in real world data (in my experience), no that's not so bad.
> 
> It also gives a reasonable route to encode RDF Containers (which seem to be equally unpopular, but more common), so it seems like a good idea. 
> 
> - Steve
> 
Received on Sunday, 3 April 2011 08:13:08 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:25:41 GMT