3
1

How can I use Jena to serialize RDF in the JSON syntax proposed by Talis?

asked 17 Aug '10, 15:26

Egon%20Willighagen's gravatar image

Egon Willigh...
1.5k513
accept rate: 12%

Are you looking for something other than 'write an RDFWriter for talis / json'?

(17 Aug '10, 15:42) Comment Bot Comment%20Bot's gravatar image

Ummm... yes, I would :)

(17 Aug '10, 18:51) Egon Willigh... Egon%20Willighagen's gravatar image

But the thought has crossed my mind... but the deadline I am facing right now (Sunday) will likely not allow me too...

(17 Aug '10, 18:52) Egon Willigh... Egon%20Willighagen's gravatar image

It would be good to see if there are other JSON Jena writers around and/or make a comparison between the different JSON proposed syntaxes to serialize RDF.

(17 Aug '10, 18:53) castagna castagna's gravatar image

Hi Egon, have a look at JSONJenaWriter on the n2 SVN repo.

If you give it a try, please, send me a feedback and if you want we could clean it up together and improve it.

See also:

permanent link

answered 17 Aug '10, 18:51

castagna's gravatar image

castagna
1.4k1415
accept rate: 27%

edited 18 Aug '10, 05:09

Oh, looks very promising! Can you link me to some license information on copyright and licensing? I would like to redistribute...

(17 Aug '10, 18:53) Egon Willigh... Egon%20Willighagen's gravatar image

Do you have to have a matching reader too?

(17 Aug '10, 19:16) Egon Willigh... Egon%20Willighagen's gravatar image

License is (now) Apache License, Version 2.0. There isn't a matching Jena Reader, as far as I know. But have a look at JSONParser.java (http://n2.talis.com/svn/jena/rdf-writers/trunk/src/test/java/com/talis/rdfwriters/json/JSONParser.java) in the tests.

(18 Aug '10, 05:18) castagna castagna's gravatar image

Releases are here: http://oss.talisplatform.com/content/repositories/talis-releases/com/talis/jena/rdf-json/

(27 Oct '10, 15:21) castagna castagna's gravatar image

Not a direct answer, since you specifically want the Talis format, but the Jena-based code we use for the linked-data API json format (Talis were also part of developing that) is at: http://code.google.com/p/linked-data-api/source/browse/#svn/trunk/json-rdf

Some improvements and packaging for that are on the (infinite) todo list.

permanent link

answered 18 Aug '10, 06:58

Dave%20Reynolds's gravatar image

Dave Reynolds
3.1k311
accept rate: 46%

Not related to Talis format, but this is the first result to show on Google. With your result set, e.g. ResultSet resultSet = qe.execSelect();

Output to console

ResultSetFormatter.outputAsJSON(resultSet);

Write to a String

There is an overloaded outputAsJson method with an OutputStream as the first parameter. Use ByteArrayOutputStream to get the JSON into a String:

ByteArrayOutputStream b = new ByteArrayOutputStream();
ResultSetFormatter.outputAsJSON(b, resultSet);
String json = b.toString( );
permanent link

answered 21 Nov '12, 14:44

bcoughlan's gravatar image

bcoughlan
635
accept rate: 0%

edited 21 Nov '12, 14:45

There is a RDF/JSON writer.

Ensure it is loaded:

SysRIOT.init()

then

model.write(System.out, "RDF/JSON") ;

Anything that has touched ARQ wil load it but the explicit init call is safe to call repeatedly.. This will soon be redundant but remain harmless.

SysRIOT augments Jena with the new parser and writers. It will become the standard set.

permanent link

answered 21 Nov '12, 17:29

AndyS's gravatar image

AndyS ♦
13.5k37
accept rate: 33%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×877
×23
×15

question asked: 17 Aug '10, 15:26

question was seen: 4,270 times

last updated: 21 Nov '12, 17:29