animedex.render.json_renderer
JSON renderer with optional source attribution.
When render_json() is called with include_source=True (the
default), the resulting JSON carries a top-level _meta block and
preserves the source field from the model. Setting
include_source=False returns the model’s clean
pydantic.BaseModel.model_dump() form: per-field source keys
remain (they are part of the schema), but no _meta is injected.
render_json
- animedex.render.json_renderer.render_json(model: AnimedexModel, *, include_source: bool = True) str[source]
Render a model to a JSON string.
The function emits the same field-level shape pydantic would produce via
AnimedexModel.model_dump_json(); wheninclude_sourceis true it additionally injects a top-level_metablock that names the upstream(s) consulted, derived from thesourcefield on the model. The block lets a CLI consumer answer “where did this row come from” without inspecting every field.- Parameters:
model (AnimedexModel) – The
AnimedexModelinstance to render.include_source (bool) – When
True(default), include the_meta.sources_consultedblock. WhenFalse, omit it (this matches the--source-attribution=offflag).
- Returns:
A JSON-encoded string.
- Return type: