# schema-coerce
[](https://crates.io/crates/schema-coerce)
Coerce LLM JSON values to a simple field-schema. String→int, `"yes"`→
`true`, unwrap `{"result": {...}}` wrappers, fill missing fields from
defaults.
```rust
use schema_coerce::{coerce, Field, Type};
use serde_json::json;
let schema = vec![
Field { name: "count", ty: Type::Int, default: None },
Field { name: "ok", ty: Type::Bool, default: Some(json!(false)) },
];
let raw = json!({ "count": "42", "ok": "yes" });
let fixed = coerce(raw, &schema);
assert_eq!(fixed["count"], json!(42));
```
Pair with `llm-json-repair` (parse) and `json-pluck` (extract). MIT
or Apache-2.0.