# jsonld-rapper

> Convert between RDF and JSON-LD using rapper

Latest version **0.2.5** (published 2018-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install jsonld-rapper
pnpm add jsonld-rapper
yarn add jsonld-rapper
bun add jsonld-rapper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.5 |
| Published | 2018-01-03 |
| First published | 2015-03-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | kba |
| Maintainers | kba |

## Links

- npm: https://www.npmjs.com/package/jsonld-rapper
- Repository: https://github.com/kba/jsonld-rapper
- Issues: https://github.com/kba/jsonld-rapper/issues
- npm.io page: https://npm.io/package/jsonld-rapper

## Dependencies (7)

- [n3](https://npm.io/package/n3.md) ^0.4.5
- [async](https://npm.io/package/async.md) ^1.5.2
- [merge](https://npm.io/package/merge.md) ^1.2.0
- [which](https://npm.io/package/which.md) ^1.3.0
- [colors](https://npm.io/package/colors.md) ^1.1.2
- [jsonld](https://npm.io/package/jsonld.md) ^0.4.12
- [jsonld-common-contexts](https://npm.io/package/jsonld-common-contexts.md) ^0.1.1

## Recent versions

- 0.2.5 (latest) — 2018-01-03
- 0.2.4 — 2017-03-25
- 0.2.3 — 2016-02-11
- 0.2.2 — 2015-12-10
- 0.2.1 — 2015-12-01
- 0.2.0 — 2015-11-30
- 0.1.0 — 2015-11-12
- 0.0.18 — 2015-11-10
- 0.0.17 — 2015-10-20
- 0.0.15 — 2015-10-20
- 0.0.14 — 2015-08-27
- 0.0.13 — 2015-05-21
- 0.0.12 — 2015-04-14
- 0.0.11 — 2015-04-13
- 0.0.10 — 2015-04-09
- … 9 more at https://npm.io/package/jsonld-rapper/versions

## README

jsonld-rapper
==============

Convert between RDF and JSON-LD using rapper

[![Build Status](https://travis-ci.org/infolis/jsonld-rapper.svg?branch=master)](https://travis-ci.org/infolis/jsonld-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

```javascript
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 the `convert` method

### Options

* `rapperBinary`: Absolute path or $PATH-relative path to the `rapper(1)` binary
* `baseURI`:  TODO
* `expandContext`: TODO
* `profile`: JSON-LD profile to use when outputting JSON-LD
* `jsonldToRDF`: Options passed to `jsonld.toRDF`. Defaults:
  * `baseURI`: Instance's `baseURI`
  * `expandContext`: Instance's `expandContext`
  * `format`: 'application/nquads'. Since the jsonld module supports only nquads, don't change this.
* `jsonldFromRDF`: Options passed to `jsonld.fromRDF`. Defaults
  * `format`: 'application/nquads'. Since the jsonld module supports only nquads, don't change this.
  * `useRdfType`: false
  * `useNativeTypes`: false
* `jsonldCompact`, `jsonldExpand`, `jsonldFlatten`: Options passed to jsonld's resp. function


### Convert

```javascript
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 object
* `from`: One of the supported input media types or short names
* `to`: One of the supported output media types or short names
* `methodOpts` (**OPTIONAL**): Options to override the instance-wide options
* `callback`: Callback, gets passed `(err, converted)` where `err` is an error
    object (including a `cause` field for errors from `rapper`) and `converted` is
    the converted RDF/JSON-LD string/object.

### Constants

Properties of the JsonLD2RDF instance

* `SUPPORTED_INPUT_TYPE`: Supported input types used as the `from` argument
* `SUPPORTED_OUTPUT_TYPE`: Supported output types used as the `from` argument
* `JSONLD_PROFILE`: Supported JSON-LD profiles

```javascript
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](./LICENSE) under the terms of the [MIT license](http://opensource.org/licenses/MIT).

Library                                                    | License
--------                                                   | --------
[async](https://github.com/caolan/async)                   | [MIT](http://opensource.org/licenses/MIT)
[colors](https://github.com/Marak/colors.js)               | [MIT](http://opensource.org/licenses/MIT)
[merge](https://github.com/yeikos/js.merge)                | [MIT](http://opensource.org/licenses/MIT)
[jsonld](https://github.com/digitalbazaar/jsonld.js)       | [BSD 3-Clause](http://opensource.org/licenses/BSD-3-Clause)
[n3](https://github.com/RubenVerborgh/N3.js)               | [MIT](http://opensource.org/licenses/MIT)
[which](https://github.com/isaacs/node-which)              | [ISC](http://opensource.org/licenses/ISC)
[which](https://github.com/infolis/jsonld-common-contexts) | [MIT](http://opensource.org/licenses/MIT)

---
_Source: https://npm.io/package/jsonld-rapper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
