RE: JSON-LD from Turtle/N-Triples in JS

Hi Adrian,

On Saturday, January 18, 2014 6:43 PM, Adrian Gschwend wrote:
> Googling didn't help so I ask here: I can parse Turtle/N-Triples with
> Rubens N3.js or some other libraries like rdfstore (which use N3
> again).
> Now the question is how do I serialize JSON-LD out of it, anyone knows
> of a direct way?

I assume you are looking for something in JavaScript, right. If so, you
should have a look at Dave's JSON-LD parser:

It is able to parse N-Quads (and thus also N-Triples) and turn that into

> If not, what's the easiest JSON-LD structure I would
> have to generate to get there?

The absolute easiest thing is to create an array containing your triples
like so:

  { "@id": "", "": "with a
literal value" },
  { "@id": "subj", "prop": { "@id": "" } },
  { "@id": "subj", "prop": { "@value": "typed literal", "@type":
"" } }

If you want to avoid the top-level array, just specify the default graph

  "@graph": [ ... array as above ]


Markus Lanthaler

Received on Saturday, 18 January 2014 17:53:44 UTC