Documentation
¶
Overview ¶
Package jsonutil provides JSON formatting utilities.
The package supports pretty printing with indentation. Keys are always sorted alphabetically by Go's json.Marshal, ensuring consistent output for diffing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TryFormat ¶
TryFormat attempts to format a JSON string with indentation. Returns the formatted string and true if successful, or the original string and false if not valid JSON. This is useful for commands that need to know whether formatting was applied.
HTML escaping is disabled so that characters like &, <, > survive verbatim instead of being mangled into &, <, > — secret/parameter values are not HTML and are never rendered in a browser context.
Numbers are decoded with UseNumber so their exact literal is preserved: decoding into float64 (the default) silently loses integer precision beyond 2^53 and collapses 1.0/1, which would make genuinely different values format identically (and diff as "identical").
func TryFormatOrWarn ¶
TryFormatOrWarn formats JSON or warns and returns original. If name is non-empty, includes it in the warning message.
Types ¶
This section is empty.