JSON Export¶
JSON export preserves the structured AST shape for downstream processing. It can
include optional fields and image payloads based on JsonOptions.
from rtfstruct import JsonOptions, parse_rtf
document = parse_rtf(r"{\rtf1\ansi Hello}")
data = document.to_json(options=JsonOptions(include_nulls=False))
- class rtfstruct.JsonOptions(include_nulls=False, include_diagnostics=True, include_image_data=False)[source]¶
JSON export configuration.
- Parameters:
include_nulls (bool)
include_diagnostics (bool)
include_image_data (bool)
JSON exporter for the document AST.
The exporter consumes AST nodes only. It does not inspect RTF source text or perform parser recovery.