Reads RDF N-Triple/N-Quads that are sorted by subject and append a JSON/JSON-LD document per line in a designated output file.
rdf2json [options] --input filename.nt --output filename.json
RDF N-Triples/N-Quads need to be sorted by subject, so that it is possible to output JSON/JSON-LD documents on-the-fly, without holding the entire input in memory or falling back to time consuming file-pointer seek operations.
Both RDF formats can be sorted on Mac OS X and Linux using the following shell command:
sort -k 1,1 UNSORTED.EXT > SORTED.EXT
--input FILE: Input file for the conversion; either RDF N-Triples or N-Quads.
--output FILE: Output file to which JSON-LD/JSON is appended.
--minimize: Minimize JSON-LD to plain (semantically untyped) JSON.
--namespace [NAMESPACE]: Alternative name for JSON-LD's "@id" key; replaces it; turns on
--prefix [PREFIX]: Prefix that should be removed from keys; requires
--triples: Input file is in RDF N-Triples format.
--quads: Input file is in RDF N-Quads format.
--silent: Do not output summary statistics.
--version: Displays the version number of the software.
--help: Show this message.
JSON output (
- replaces "@id" keys with an alternative name if the
--namespaceoption is present
- keys that start with the prefix of
--prefixare shortened (prefix is removed)
- array contents are "lifted up", i.e. for each entry of the array:
- hashes with a "@value" key are replaced by the value of "@value", or else
- hashes with a "@id" key are replaced by the value of "@id", or else
- the array value is left unchanged
- removes all "@type" key/value pairs
gem install rdf2json
Project home page
Information on the source tree, documentation, examples, issues and how to contribute, see
The BioRuby community is on IRC server: irc.freenode.org, channel: #bioruby.
This Biogem is published at (http://biogems.info/index.html#bio-rdf2json)
Copyright (c) 2014 Joachim Baran. See LICENSE.txt for further details.