[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"c07IfcTTcJ":3},"# lean4-json-schema\n\nA Lean 4 library for [JSON Schema](https://json-schema.org/) with types, validation, correctness proofs, and type class deriving handlers.\n\n> [!WARNING]\n> This library is under active development and **does not yet fully cover the JSON Schema standard**. We are actively using it to build [Predictable Code](https://predictablemachines.com/tools/predictable-code/), but the API surface, type definitions, and proof interfaces may change without notice. The current correctness proofs might not cover the full extent of the functionality provided in the library. Use at your own discretion.\n\n## Features\n\n- **Schema Types**: `JSONSchema` inductive type with full JSON Schema support (`SchemaKind`, `HasJSONSchema` typeclass)\n- **Validation**: Total (non-partial) `validateJson` function for runtime validation against schemas\n- **Correctness Proofs**: Soundness and completeness theorems, bridge theorems connecting schema derivation to validation\n- **Deriving Handlers**: `deriving HasJSONSchema` and `deriving ValidatesAgainstSchema` for enums, structures, and inductives (including recursive types with `$defs`/`$ref`)\n\n## Usage\n\nAdd to your `lakefile.lean`:\n\n```lean\nrequire «json-schema» from git\n  \"https://github.com/predictable-machines/lean4-json-schema\" @ \"v0.1.0\"\n```\n\nThen import in your Lean files:\n\n```lean\nimport JsonSchema\n\n-- Derive schema for a structure\nstructure Person where\n  name : String\n  age : Nat\n  deriving HasJSONSchema\n\n-- Derive validation proof\nstructure Person where\n  name : String\n  age : Nat\n  deriving HasJSONSchema, ValidatesAgainstSchema\n\n-- Validate JSON at runtime\n#eval validateJson (HasJSONSchema.schema Person) (Lean.Json.mkObj [(\"name\", \"Alice\"), (\"age\", 30)])\n```\n\n## Building\n\n```bash\nlake build\n```\n\n## License\n\nMIT\n",1780241990178]