0.2.5 • Published 7 years ago
jsonld-rapper v0.2.5
jsonld-rapper
Convert between RDF and JSON-LD using rapper
Installation
This module requires the rapper
utility, version >=2.0.14 to be in $PATH
.
If it isn't in the $PATH
, override rapperBinary
.
Based on https://github.com/ruby-rdf/rdf-raptor:
% [sudo] port install raptor # Mac OS X with MacPorts
% [sudo] fink install raptor-bin # Mac OS X with Fink
% brew install raptor # Mac OS X with Homebrew
% [sudo] apt-get install raptor2-utils # Ubuntu / Debian with apt-get
% [sudo] yum install raptor2 # Fedora / CentOS / RHEL
% [sudo] zypper install raptor # openSUSE
% [sudo] emerge raptor # Gentoo Linux
% [sudo] pacman -S raptor # Arch Linux
% [sudo] pkg_add -r raptor # FreeBSD
% [sudo] pkg_add raptor # OpenBSD / NetBSD
Install dependencies: npm install
Test: npm test
Generate docs in apidocs
: npm run docs
Example
var JsonLD2RDF = require('jsonld-rapper')
var j2r = new JsonLD2RDF();
var jsonld1 = {'@id': 'http://example.org/foo', 'http://example.org/prop1': 'bar'};
var turtle1 = {'@prefix ex: <http://example.org/> .\n ex:foo ex:prop1 "bar" .'
j2r.convert(turtle1, 'turtle', 'jsonld', function (err, asJsonLD) {
// do something with asJsonLD, an object
});
j2r.convert(jsonld1, 'jsonld', 'rdfxml', function (err, asRdfxml) {
// do something with asRdfxml, a string
});
API
Exports
JsonLD2RDF
: Class with theconvert
method
Options
rapperBinary
: Absolute path or $PATH-relative path to therapper(1)
binarybaseURI
: TODOexpandContext
: TODOprofile
: JSON-LD profile to use when outputting JSON-LDjsonldToRDF
: Options passed tojsonld.toRDF
. Defaults:baseURI
: Instance'sbaseURI
expandContext
: Instance'sexpandContext
format
: 'application/nquads'. Since the jsonld module supports only nquads, don't change this.
jsonldFromRDF
: Options passed tojsonld.fromRDF
. Defaultsformat
: 'application/nquads'. Since the jsonld module supports only nquads, don't change this.useRdfType
: falseuseNativeTypes
: false
jsonldCompact
,jsonldExpand
,jsonldFlatten
: Options passed to jsonld's resp. function
Convert
var JsonLD2RDF = require('jsonld-rapper');
var j2r = new JsonLD2RDF();
j2r.convert(input, from, to, methodOpts, callback)
input
: string of RDF/JSON-LD or JSON-LD objectfrom
: One of the supported input media types or short namesto
: One of the supported output media types or short namesmethodOpts
(OPTIONAL): Options to override the instance-wide optionscallback
: Callback, gets passed(err, converted)
whereerr
is an error object (including acause
field for errors fromrapper
) andconverted
is the converted RDF/JSON-LD string/object.
Constants
Properties of the JsonLD2RDF instance
SUPPORTED_INPUT_TYPE
: Supported input types used as thefrom
argumentSUPPORTED_OUTPUT_TYPE
: Supported output types used as thefrom
argumentJSONLD_PROFILE
: Supported JSON-LD profiles
var JsonLD2RDF = require('jsonld-rapper');
var j2r = new JsonLD2RDF();
for (profile in j2r.JSONLD_PROFILE) {
console.log profile
}
// COMPACTED => 'http://www.w3.org/ns/json-ld#compacted'
// FLATTENED => 'http://www.w3.org/ns/json-ld#flattened'
// FLATTENED_EXPANDED => 'http://www.w3.org/ns/json-ld#flattened+expanded'
// EXPANDED => 'http://www.w3.org/ns/json-ld#expanded'
Rights
This library is licensed under the terms of the MIT license.
Library | License |
---|---|
async | MIT |
colors | MIT |
merge | MIT |
jsonld | BSD 3-Clause |
n3 | MIT |
which | ISC |
which | MIT |
0.2.5
7 years ago
0.2.4
8 years ago
0.2.3
9 years ago
0.2.2
10 years ago
0.2.1
10 years ago
0.2.0
10 years ago
0.1.0
10 years ago
0.0.18
10 years ago
0.0.17
10 years ago
0.0.15
10 years ago
0.0.14
10 years ago
0.0.13
10 years ago
0.0.12
10 years ago
0.0.11
10 years ago
0.0.10
10 years ago
0.0.9
10 years ago
0.0.8
10 years ago
0.0.7
10 years ago
0.0.6
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago