Re: Can JSON-LD cater for Talis' RDF/JSON design goals?

On 08/26/2011 06:54 AM, Richard Cyganiak wrote:
> On 26 Aug 2011, at 10:32, Thomas Steiner wrote:
>>> This gives me hope that there could be a way forward to produce
>>> only a single JSON spec.
>>
>> I think this is the most important part of your email :-) Me too,
>> I strongly believe in the fact that both needs (RDF geek's, Web
>> developer's) can be addressed by one spec.
>
> The way to do this might be to define in the spec some sort of “RDF
> geek compatibility context” that could be used by anyone who wants a
> very regular and direct representation of RDF triples in JSON-LD. For
> example, my SPARQL store could use that context when serializing a
> CONSTRUCT result to JSON-LD.

I think a few lines of JavaScript could transform JSON-LD normalized 
form into the Talis RDF/JSON form.

> If that would be possible, then I'd consider JSON-LD as addressing
> the use cases that motivate RDF/JSON [1].

I think it's possible... basically, you'd write a loop to go through 
each array item in JSON-LD normalized form array and create a new map 
that looks like the Talis RDF/JSON serialization:

for obj in jsonld_normalized:
    map[obj["@subject"]] = obj;
    delete obj["@subject"];

I think that pseudocode above basically gives you the Talis RDF/JSON 
format. Do you want a proof in code? If you do, I would just need to 
find the time to hack something together.

-- manu

--
Manu Sporny (skype: msporny, twitter: manusporny)
Founder/CEO - Digital Bazaar, Inc.
blog: Building a Better World with Web Payments
http://manu.sporny.org/2011/better-world/

Received on Monday, 29 August 2011 02:05:12 UTC