Learn R Programming

schemate (version 0.1.0)

schema_compact: Compact a schema document

Description

schema_compact() simplifies schema documents produced by inference or hand-authoring. It can merge observed array element alternatives and group sibling fields that share identical schemas.

Usage

schema_compact(x, arrays = TRUE, groups = TRUE)

Value

A compacted SchemaDoc.

Arguments

x

A SchemaDoc or raw schema DSL list.

arrays

Whether to merge compatible any branches, especially the observed element alternatives produced by schema_infer(arrays = "rest").

groups

Whether to combine sibling fields with identical schemas into groups.

Examples

Run this code
schema <- schema_infer(
    list(items = list(list(id = 1L, name = "a"), list(id = 2L, label = "b"))),
    keys = "named",
    arrays = "rest"
)
schema

schema_compact(schema)

Run the code above in your browser using DataLab