Title: | JSON for Linking Data |
---|---|
Description: | JSON-LD <https://www.w3.org/TR/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. |
Authors: | Jeroen Ooms [aut, cre] |
Maintainer: | Jeroen Ooms <[email protected]> |
License: | BSD_3_clause + file LICENSE |
Version: | 2.2.1 |
Built: | 2024-12-02 05:43:22 UTC |
Source: | https://github.com/ropensci/jsonld |
Wrappers for converting, expanding and compacting JSON-LD documents. All parameters and return values must be JSON strings. Use jsonlite::toJSON and jsonlite::fromJSON to convert between R objects and JSON format. The readme has basic examples.
jsonld_compact(doc, context, options = NULL) jsonld_expand(compacted, options = NULL) jsonld_flatten(doc, context = NULL, options = NULL) jsonld_frame(doc, frame, options = NULL) jsonld_from_rdf(rdf, options = list(format = "application/nquads")) jsonld_to_rdf(doc, options = list(format = "application/nquads")) jsonld_normalize(doc, options = list(algorithm = "URDNA2015", format = "application/nquads"))
jsonld_compact(doc, context, options = NULL) jsonld_expand(compacted, options = NULL) jsonld_flatten(doc, context = NULL, options = NULL) jsonld_frame(doc, frame, options = NULL) jsonld_from_rdf(rdf, options = list(format = "application/nquads")) jsonld_to_rdf(doc, options = list(format = "application/nquads")) jsonld_normalize(doc, options = list(algorithm = "URDNA2015", format = "application/nquads"))
doc |
a URL or literal string with JSON-LD document |
context |
a URL or literal string with JSON-LD context |
options |
named list with advanced options |
compacted |
a URL or literal string with JSON message |
frame |
a URL or literal string with JSON-LD frame |
rdf |
string with RDF text |
# Example from https://github.com/digitalbazaar/jsonld.js#quick-examples 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))
# Example from https://github.com/digitalbazaar/jsonld.js#quick-examples 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))