You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Zen 98052 <z9...@outlook.com> on 2015/09/21 19:35:01 UTC

return model as json

Hi,

There is ResultSetFormatter.outputAsJSON to return the result set (from SELECT command) as JSON response to the client.

For CONSTRUCT and DESCRIBE commands, they are returning Model instead of ResultSet, is there a similar helper function to return the JSON response back to client?



Thanks,

Z

Re: return model as json

Posted by Zen 98052 <z9...@outlook.com>.
Thanks Andy! Right after I posted this question, I found the solution online, http://t6188.apache-jena-user.apacheforum.info/writing-jena-model-out-as-json-t6188.html
I just tried it, model.write(stream, "RDF/JSON") works like a charm!


Thanks,
Z
________________________________________
From: Andy Seaborne <an...@apache.org>
Sent: Monday, September 21, 2015 2:40 PM
To: users@jena.apache.org
Subject: Re: return model as json

On 21/09/15 18:35, Zen 98052 wrote:
> Hi,
>
> There is ResultSetFormatter.outputAsJSON to return the result set (from SELECT command) as JSON response to the client.
>
> For CONSTRUCT and DESCRIBE commands, they are returning Model instead of ResultSet, is there a similar helper function to return the JSON response back to client?
>
>
>
> Thanks,
>
> Z
>

Models can be written as JSON-LD or as RDF/JSON.

(You may find it useful to see the result handling in Fuseki2)

        Andy

Re: return model as json

Posted by Andy Seaborne <an...@apache.org>.
On 21/09/15 18:35, Zen 98052 wrote:
> Hi,
>
> There is ResultSetFormatter.outputAsJSON to return the result set (from SELECT command) as JSON response to the client.
>
> For CONSTRUCT and DESCRIBE commands, they are returning Model instead of ResultSet, is there a similar helper function to return the JSON response back to client?
>
>
>
> Thanks,
>
> Z
>

Models can be written as JSON-LD or as RDF/JSON.

(You may find it useful to see the result handling in Fuseki2)

	Andy