Skip to main content

from_json

Function from_json 

Source
pub fn from_json(json: &str) -> Result<Document, String>
Expand description

Convert JSON (array or object) into a SIF Document (§25.3).

Handles:

  • [{...}, {...}] — array of objects → single section
  • [1, "two"] — array of scalars → single section
  • {"items":[{...}]} — wrapper with array → extracts largest array
  • {"paths": {"k": {...}, ...}} — object-of-objects → each value becomes a record
  • {...} — single object → single record

For complex objects with multiple large children (like OpenAPI specs), each top-level key that holds significant data becomes its own section per §25.4 guidance on splitting sparse datasets.