W3C home > Mailing lists > Public > public-linked-json@w3.org > June 2011

Re: experiences promoting a JSON format for RDF

From: Manu Sporny <msporny@digitalbazaar.com>
Date: Wed, 01 Jun 2011 22:42:35 -0400
Message-ID: <4DE6F89B.4030808@digitalbazaar.com>
To: public-linked-json@w3.org
On 05/31/2011 02:47 AM, Richard Cyganiak wrote:
> On 31 May 2011, at 03:37, Brian Peterson wrote:
>> I ended up rolling up multiple values into a JSON array. So if I
>> had multiple phone numbers, then it would be
>> phoneNumber : ["123-555-6789", "111-222-3333"]
> Did you decide on the fly whether to use an array or a simple value?
> That is, if Alice has one phone number and Bob has two, would Alice
> get a simple string value and Bob an array of strings?


We've found that we cannot write fully generic code without
post-processing the JSON-LD that we get in. That is, we're consistent in
what we publish, but when we get JSON-LD in from developers, we cannot
expect that they will follow the same strict rules that we use to
generate "clean" JSON-LD.

That is, for the example above, we would expect that some developers
would send us:

 phoneNumber: "123-555-6789"

While others would send us:

 phoneNumber: ["123-555-6789", "111-222-3333"]

Our code would have to have endless if/then statements to check to see
if the value is a string or an array and if it is an array, process the
array. Instead, we have created a system of "framing" that is sort of
like a "projection template" described by the "Projection" interface
provided by the RDFa API:


In other words, the "framing" code in JSON-LD would always give you an
object formatted in a way that you expect. For the example above, you
could provide a "frame" that would always give you an array of strings
for "phoneNumber".

We found that this greatly simplified the code that developers had to
write for systems that accepted arbitrary JSON-LD input.

-- manu

Manu Sporny (skype: msporny, twitter: manusporny)
President/CEO - Digital Bazaar, Inc.
blog: PaySwarm Developer Tools and Demo Released
Received on Thursday, 2 June 2011 02:43:11 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:18:29 UTC