Writes a Croissant object as a JSON-LD document with the standard
context of its version (see croissant_context()). conformsTo always
includes the Croissant IRI of x@version.
Value
If path is NULL, the JSON text as a character scalar of class
json; otherwise path, invisibly.
Details
In version 1.1, a name or description named by language tag is written as
a language map. In version 1.0, it is written as an array of
@value/@language objects.
Examples
x <- Croissant(
name = "Titanic",
distribution = list(
FileObject(id = "passengers.csv", content_url = "titanic.csv", encoding_format = "text/csv")
)
)
cat(write_croissant(x))#> {
#> "@context": {
#> "@language": "en",
#> "@vocab": "https://schema.org/",
#> "annotation": "cr:annotation",
#> "arrayShape": "cr:arrayShape",
#> "citeAs": "cr:citeAs",
#> "column": "cr:column",
#> "conformsTo": "dct:conformsTo",
#> "containedIn": "cr:containedIn",
#> "cr": "http://mlcommons.org/croissant/",
#> "data": {
#> "@id": "cr:data",
#> "@type": "@json"
#> },
#> "dataBiases": "cr:dataBiases",
#> "dataCollection": "cr:dataCollection",
#> "dataType": {
#> "@id": "cr:dataType",
#> "@type": "@vocab"
#> },
#> "dct": "http://purl.org/dc/terms/",
#> "description": {
#> "@container": "@language"
#> },
#> "equivalentProperty": "cr:equivalentProperty",
#> "examples": {
#> "@id": "cr:examples",
#> "@type": "@json"
#> },
#> "extract": "cr:extract",
#> "field": "cr:field",
#> "fileObject": "cr:fileObject",
#> "fileProperty": "cr:fileProperty",
#> "fileSet": "cr:fileSet",
#> "format": "cr:format",
#> "includes": "cr:includes",
#> "isArray": "cr:isArray",
#> "isLiveDataset": "cr:isLiveDataset",
#> "jsonPath": "cr:jsonPath",
#> "key": "cr:key",
#> "md5": "cr:md5",
#> "name": {
#> "@container": "@language"
#> },
#> "parentField": "cr:parentField",
#> "path": "cr:path",
#> "personalSensitiveInformation": "cr:personalSensitiveInformation",
#> "prov": "http://www.w3.org/ns/prov#",
#> "rai": "http://mlcommons.org/croissant/RAI/",
#> "readLines": "cr:readLines",
#> "recordSet": "cr:recordSet",
#> "references": "cr:references",
#> "regex": "cr:regex",
#> "repeated": "cr:repeated",
#> "replace": "cr:replace",
#> "samplingRate": "cr:samplingRate",
#> "sc": "https://schema.org/",
#> "sdVersion": "cr:sdVersion",
#> "separator": "cr:separator",
#> "source": "cr:source",
#> "subField": "cr:subField",
#> "transform": "cr:transform",
#> "unArchive": "cr:unArchive",
#> "value": "cr:value",
#> "wd": "https://www.wikidata.org/wiki/"
#> },
#> "@type": "sc:Dataset",
#> "name": "Titanic",
#> "conformsTo": "http://mlcommons.org/croissant/1.1",
#> "distribution": [
#> {
#> "@type": "cr:FileObject",
#> "@id": "passengers.csv",
#> "contentUrl": "titanic.csv",
#> "encodingFormat": "text/csv"
#> }
#> ]
#> }path <- tempfile(fileext = ".json")
write_croissant(x, path)
read_croissant(path)#> <Croissant>
#> name: Titanic
#> version: Croissant 1.1
#> distribution: 1 FileObject
#> record sets: 0
#>