Stringify-text-formatter-config
Serialize TextFormatterConfig into JSON text. This helper is the highest-level export path when formatter config should be printed, logged, or copied as config text.
Interface
pub fn stringify_text_formatter_config(
config : TextFormatterConfig,
pretty~ : Bool = false,
) -> String {}input
config : TextFormatterConfig- Formatter config to serialize.pretty : Bool- Whether JSON should be pretty-printed.
output
String- Serialized JSON text for the formatter config.
Explanation
Detailed rules explaining key parameters and behaviors
pretty=falsereturns compact JSON.pretty=truereturns indented JSON for humans.- This helper is built on top of
text_formatter_config_to_json(...). - Internally it serializes the
JsonValueresult with@json_parser.stringify(...)or@json_parser.stringify_pretty(value, 2), so the text form stays aligned with the structured formatter export helper. - The output preserves the supported formatter config schema instead of any runtime-only formatter instance details.
How to Use
Here are some specific examples provided.
When Need Human-readable Formatter Config
When formatter settings should be inspected during setup:
println(stringify_text_formatter_config(default_text_formatter_config(), pretty=true))In this example, the pretty output is suitable for diagnostics or docs.
When Need Compact Export Text
When generated config should stay small:
let text = stringify_text_formatter_config(
TextFormatterConfig::new(show_fields=false),
)In this example, compact JSON is returned for storage or transport.
Error Case
e.g.:
If callers need a JSON value for composition, they should use
text_formatter_config_to_json(...)instead.If
style_tagsis empty, the serialized text omits that field rather than forcing an empty object.
Notes
Use this helper when the next consumer expects JSON text instead of
JsonValue.Use
text_formatter_config_to_json(...)when you still need to embed formatter config inside a larger JSON object before final stringification.