- From: Manu Sporny <msporny@digitalbazaar.com>
- Date: Wed, 01 Jun 2011 22:42:35 -0400
- 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? Richard, 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: http://www.w3.org/TR/2011/WD-rdfa-api-20110419/#advanced-concepts 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 http://digitalbazaar.com/2011/05/05/payswarm-sandbox/
Received on Thursday, 2 June 2011 02:43:11 UTC