Reads a Croissant JSON-LD document into a Croissant object. A document
whose @context defines only standard Croissant terms is read with
'jsonlite'. A document with any other context is first compacted against
the standard context by the 'jsonld' package, which must then be installed.
Arguments
- x
Character: Path to a Croissant JSON-LD file, an
http(s)URL, a JSON string, or anhf://datasets/path. A path naming a file of a Hugging Face dataset reads that file; one naming the dataset only, ashf://datasets/<owner>/<name>, reads the Croissant metadata the Hub generates for it, asread_croissant_hf()does.
Details
Croissant 1.0 and 1.1 documents are supported. A 0.8 document, or one that
conforms to another version, raises an error of class
croissant_version_error.
Examples
json <- '{
"@context": {"@vocab": "https://schema.org/", "cr": "http://mlcommons.org/croissant/",
"recordSet": "cr:recordSet", "field": "cr:field",
"dataType": {"@id": "cr:dataType", "@type": "@vocab"}},
"@type": "sc:Dataset",
"name": "minimal",
"conformsTo": "http://mlcommons.org/croissant/1.1",
"recordSet": [{"@type": "cr:RecordSet", "@id": "rs", "field": [
{"@type": "cr:Field", "@id": "rs/x", "dataType": "sc:Integer"}]}]
}'
x <- read_croissant(json)#> Warning: [Croissant] The key `conformsTo` is a Croissant term, but the @context does not define it, so it expands to https://schema.org/conformsTo and is not read as the Croissant property. Add the standard definition of `conformsTo` to the @context.
#> Warning: [Croissant] The document has no conformsTo IRI of the form http://mlcommons.org/croissant/<version>, so it is read as Croissant 1.0. Add conformsTo with the version the document follows.x#> <Croissant>
#> name: minimal
#> version: Croissant 1.0
#> distribution: none
#> record sets: 1
#> rs: 1 field