Expand description
Validate JSON with JSON Schema and render it as Markdown.
A View compiles one schema and one template for repeated use. Every
View::render validates its input before running the template.
use json2md::View;
use serde_json::json;
let schema = json!({
"type": "object",
"properties": {"title": {"type": "string"}},
"required": ["title"]
});
let view = View::new(&schema, "# {{ title }}\n")?;
assert_eq!(view.render(&json!({"title": "Release notes"}))?, "# Release notes\n");Templates use MiniJinja syntax. Missing values are strict and output has no automatic escaping. Callers own file I/O, Markdown escaping, and the trust policy for their schemas, templates, input, and output.
Structs§
- Validation
Errors - A nonempty collection of owned validation failures.
- Validation
Issue - A validation failure with paths into the input and its schema resource.
- View
- One compiled JSON Schema and Markdown template, reusable across inputs.
Enums§
- Error
- The stage that prevents a view from being constructed or rendered.