File: jsonld.Rd

package info (click to toggle)
r-cran-jsonld 2.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 892 kB
  • sloc: javascript: 12,209; sh: 19; makefile: 13
file content (74 lines) | stat: -rw-r--r-- 2,147 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{jsonld}
\alias{jsonld}
\alias{jsonld_compact}
\alias{jsonld_expand}
\alias{jsonld_flatten}
\alias{jsonld_frame}
\alias{jsonld_from_rdf}
\alias{jsonld_to_rdf}
\alias{jsonld_normalize}
\title{Working with JSON-LD}
\usage{
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"))
}
\arguments{
\item{doc}{a URL or literal string with JSON-LD document}

\item{context}{a URL or literal string with JSON-LD context}

\item{options}{named list with advanced options}

\item{compacted}{a URL or literal string with JSON message}

\item{frame}{a URL or literal string with JSON-LD frame}

\item{rdf}{string with RDF text}
}
\description{
Wrappers for converting, expanding and compacting JSON-LD documents. All parameters
and return values must be JSON strings. Use \link[jsonlite:toJSON]{jsonlite::toJSON} and \link[jsonlite:fromJSON]{jsonlite::fromJSON}
to convert between R objects and JSON format. The \href{https://github.com/ropensci/jsonld#readme}{readme}
has basic examples.
}
\examples{
# 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))
}