schema_read() reads schema JSON into a SchemaDoc. schema_write()
serializes schema objects to schema JSON. Both functions require the
suggested package jsonlite.
Arguments
- x
A schema object accepted by
as.list(), usually aSchemaDoc.- path
Output file path.
- overwrite
Whether an existing output file may be overwritten.
- pretty
Whether JSON output should be pretty-printed.
- auto_unbox
Passed to
jsonlite::write_json().- txt
JSON text, local file path, or URL accepted by
jsonlite::fromJSON().
Examples
schema <- schema_infer(list(id = 1L))
schema
#> {
#> "check": {
#> "kind": "list"
#> },
#> "fields": {
#> "id": {
#> "check": {
#> "kind": "int"
#> }
#> }
#> }
#> }
path <- tempfile(fileext = ".json")
schema_write(schema, path)
schema_read(path)
#> {
#> "check": {
#> "kind": "list"
#> },
#> "fields": {
#> "id": {
#> "check": {
#> "kind": "int"
#> }
#> }
#> }
#> }