JSON for Linking Data
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.
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"} }'
(out <- jsonld_compact(doc, context)) (expanded <- jsonld_expand(out))
cat(nquads <- jsonld_to_rdf(doc)) jsonld_from_rdf(nquads)
jsonld_flatten(doc) cat(jsonld_normalize(doc, algorithm = 'URDNA2015', format = 'application/nquads'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.