You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Martin <m....@gmail.com> on 2023/08/14 11:44:48 UTC

riot cmd convert RDF to JSON-LD framing

Hi, 

I would like to convert RDF (on Turtle format) to JSON-LD and apply a
JSON-LD framing specification to it (*) -- and I would prefer to do
this with the command line tooling that ships with Jena.

I can transform my RDF to JSON-LD with the command

  $ riot --out=jsonld [file]

but I have not found a way to pass my context json file to the command.
Attempts like this fails or does not pick up the context file:

 $ riot --out=JSONLD_FRAME_PRETTY --set JSONLD_CONTEXT=[file] [file]

These attempts are motivated by
https://jena.apache.org/documentation/io/rdf-output.html#json-ld


Is there a way to pass a context file to riot, or otherwise achieve
what I want using Jena's command line tools? If not, what is my best
other option?

Thanks!

Martin

(*) Apologies if I am not using correct terminology for this.

JSON-LD framing

Posted by Andy Seaborne <an...@apache.org>.
Jena uses jsonld-java for JSON-LD 1.0 and titanium-json-ld for JSON-LD 1.1

Rob describes the framing support for passing information to jsonld-java 
for JSON-LD 1.0.

At Jena5, support for JSON-LD 1.0 is planned for removal. The 
jsonld-java project does not appear to be active.

The project is looking for a contribution to provide passing framing 
information to titanium-json-ld.

     Andy

https://github.com/jsonld-java/jsonld-java
https://github.com/filip26/titanium-json-ld


On 14/08/2023 15:04, Rob @ DNR wrote:
> Riot, and more generally Jena’s, configuration symbols are actually URIs internally, so the --set option needs to receive the full URI for the symbol, which I think should start with http://jena.apache.org/riot/jsonld#, not just the Java constant names as they appear in the examples/API.
> 
> Also, I don’t believe that any of these context options expect to receive a file, rather they expect to contain a chunk of JSON itself so from the command line you’d probably need something like the following:
> 
> $ export FRAME=$(cat frame.json)
> $ riot --out JSONLD_FRAME_PRETTY --set “http://jena.apache.org/riot/jsonld#JSONLD_FRAME=$FRAME” input.ttl
> 
> NB – Completely untested, I don’t use JSON-LD myself at all so no guarantees any of this will work, but hopefully this at least points you in the right direction to make progress
> 
> Rob
> 
> From: Martin <m....@gmail.com>
> Date: Monday, 14 August 2023 at 12:45
> To: users@jena.apache.org <us...@jena.apache.org>
> Subject: riot cmd convert RDF to JSON-LD framing
> Hi,
> 
> I would like to convert RDF (on Turtle format) to JSON-LD and apply a
> JSON-LD framing specification to it (*) -- and I would prefer to do
> this with the command line tooling that ships with Jena.
> 
> I can transform my RDF to JSON-LD with the command
> 
>    $ riot --out=jsonld [file]
> 
> but I have not found a way to pass my context json file to the command.
> Attempts like this fails or does not pick up the context file:
> 
>   $ riot --out=JSONLD_FRAME_PRETTY --set JSONLD_CONTEXT=[file] [file]
> 
> These attempts are motivated by
> https://jena.apache.org/documentation/io/rdf-output.html#json-ld
> 
> 
> Is there a way to pass a context file to riot, or otherwise achieve
> what I want using Jena's command line tools? If not, what is my best
> other option?
> 
> Thanks!
> 
> Martin
> 
> (*) Apologies if I am not using correct terminology for this.
> 

Re: riot cmd convert RDF to JSON-LD framing

Posted by "Rob @ DNR" <rv...@dotnetrdf.org>.
Riot, and more generally Jena’s, configuration symbols are actually URIs internally, so the --set option needs to receive the full URI for the symbol, which I think should start with http://jena.apache.org/riot/jsonld#, not just the Java constant names as they appear in the examples/API.

Also, I don’t believe that any of these context options expect to receive a file, rather they expect to contain a chunk of JSON itself so from the command line you’d probably need something like the following:

$ export FRAME=$(cat frame.json)
$ riot --out JSONLD_FRAME_PRETTY --set “http://jena.apache.org/riot/jsonld#JSONLD_FRAME=$FRAME” input.ttl

NB – Completely untested, I don’t use JSON-LD myself at all so no guarantees any of this will work, but hopefully this at least points you in the right direction to make progress

Rob

From: Martin <m....@gmail.com>
Date: Monday, 14 August 2023 at 12:45
To: users@jena.apache.org <us...@jena.apache.org>
Subject: riot cmd convert RDF to JSON-LD framing
Hi,

I would like to convert RDF (on Turtle format) to JSON-LD and apply a
JSON-LD framing specification to it (*) -- and I would prefer to do
this with the command line tooling that ships with Jena.

I can transform my RDF to JSON-LD with the command

  $ riot --out=jsonld [file]

but I have not found a way to pass my context json file to the command.
Attempts like this fails or does not pick up the context file:

 $ riot --out=JSONLD_FRAME_PRETTY --set JSONLD_CONTEXT=[file] [file]

These attempts are motivated by
https://jena.apache.org/documentation/io/rdf-output.html#json-ld


Is there a way to pass a context file to riot, or otherwise achieve
what I want using Jena's command line tools? If not, what is my best
other option?

Thanks!

Martin

(*) Apologies if I am not using correct terminology for this.