Convert or translate a big RDF/XML file to JSON-LD format - HOW?

Akku picture Akku · Sep 5, 2013 · Viewed 12.1k times · Source

I need to convert this 40MB file of RDF/XML to the JSON-LD format and I've only found this web tool, that doesn't work at all. When you paste 40MB of text, it crashes, and when you give it the URL of the file, it says that the service isn't available.

In theory the Jena API, or maybe Sesame should be able to do this, but I'm missing a starting point and the knowledge about these systems. Can someone give me a route, an example or a link to useful documentation for translating a big RDF/XML into JSON-LD?

(I'd be happy with Java, C# or a working solution where I don't need too much programming knowledge in another language / framework).

Answer

Ming Chan picture Ming Chan · Sep 13, 2013

You can just use RDFLib to read in RDF in RDF/XML format and the serialize it back to JSON-LD using the json-ld serializer

graph.parse(my_url, format='application/rdf+xml')


graph.serialize(my_url, format='application/json-ld')