Learn R Programming

schemate (version 0.1.0)

schema_write: Read and write schema JSON

Description

schema_read() reads schema JSON into a SchemaDoc. schema_write() serializes schema objects to schema JSON. Both functions require the suggested package jsonlite.

Usage

schema_write(x, path, overwrite = FALSE, pretty = TRUE, auto_unbox = TRUE)

schema_read(txt)

Value

schema_read() returns a SchemaDoc. schema_write() invisibly returns path.

Arguments

x

A schema object accepted by as.list(), usually a SchemaDoc.

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

Run this code
schema <- schema_infer(list(id = 1L))
schema

path <- tempfile(fileext = ".json")
schema_write(schema, path)

schema_read(path)

Run the code above in your browser using DataLab