Thalweg · API reference ← Main docs

Module json_schema

Module json_schema 

Source
Expand description

Maps a JSON Schema document (the declarative $schema/type/ format format, e.g. from a schema registry) to crate::pg_type::PgType. Distinct from crate::pg_type::PgType::from_json_value, which infers from an already-decoded value instead of a schema document.

Uses a depth-cutoff-then-degrade-to-JSONB pattern (max_depth/current_depth): a nested object with properties flattens into individually-named columns while depth remains, then becomes a single Jsonb column once exhausted.

Structs§

InferredColumn
One flattened column: name + inferred type. The caller decides what to do with these; this crate has no table-schema or column-definition type of its own, since that is an application bookkeeping concern, not a type-mapping one.

Functions§

flatten_json_schema
Flattens a JSON Schema document into columns, starting at column_name (pass "" for the root; nested field names are joined with _).