Skip to main content

Module schema

Module schema 

Source
Expand description

JSON Schema inference from record samples.

Given a slice of JSON values (records from a REST API), produces a JSON Schema that is valid for all of them. The algorithm:

  • Each field type is inferred independently per record then merged across records.
  • A field absent from some records gets "null" added to its type.
  • "integer" widens to "number" when the same field is an integer in some records and a float in others.
  • Nested objects are recursively inferred and merged.

Functionsยง

infer_schema
Infer a JSON Schema object descriptor from a slice of record values.