jsonld

JSON for Linking Data

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Build Status AppVeyor Build Status Coverage Status CRAN_Status_Badge CRAN RStudio mirror downloads Github Stars

JSON-LD is a light-weight syntax for expressing linked data. It is primarily intended for web-based programming environments, interoperable web services and for storing linked data in JSON-based databases. This package provides bindings to the JavaScript library for converting, expanding and compacting JSON-LD documents.

Hello World

knitr::opts_chunk$set(comment = "")
options(width = 120, max.print = 100)
library(jsonld)

Example from https://github.com/digitalbazaar/jsonld.js#quick-examples. Example data:

doc <- '{
  "http://schema.org/name": "Manu Sporny",
  "http://schema.org/url": {"@id": "http://manu.sporny.org/"},
  "http://schema.org/image": {"@id": "http://manu.sporny.org/images/manu.png"}
}'

context <- '{
  "name": "http://schema.org/name",
  "homepage": {"@id": "http://schema.org/url", "@type": "@id"},
  "image": {"@id": "http://schema.org/image", "@type": "@id"}
}'

Compact and expand:

(out <- jsonld_compact(doc, context))
(expanded <- jsonld_expand(out))

Convert between JSON and RDF:

cat(nquads <- jsonld_to_rdf(doc))
jsonld_from_rdf(nquads)

Other utilities:

jsonld_flatten(doc)
cat(jsonld_normalize(doc, algorithm = 'URDNA2015', format = 'application/nquads'))


ropensci/jsonld documentation built on June 8, 2020, 11:28 a.m.