util::json::indent (public, deprecated)
util::json::indent [ -simplify ] json
Defined in packages/acs-tcl/tcl/json-procs.tcl
Deprecated. Invoking this procedure generates a warning.
Indent a JSON string using the legacy formatter. When ns_json is available, use this type-preserving alternative:
set triples [ns_json parse -output triples -- $json] ns_json value -pretty -- $triplesThe native formatter preserves all fields. The legacy -simplify option removes fields and has no direct equivalent.
- Switches:
- -simplify (optional, boolean)
- If true, remove all fields that don't contribute to the structure of the object/array combination being described by the string.
- Parameters:
- json (required)
- The string to indent
- Returns:
- The beautifully indented, and optionally simplified, string
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: ad_log_deprecated proc util::json::indent set indent -1 set output "" set json [string map {, ,\n :\{ :\n\{ :\[ :\[\n} $json] foreach jsonette [split $json \n] { if { $simplify_p && ![regexp {[\{\[\}\]]} $jsonette] } { continue } set incr_indent [regexp "^\{" $jsonette] incr indent $incr_indent lappend output [string repeat " " $indent][expr { $incr_indent ? "" : " " }]${jsonette} incr indent [expr {[regexp -all "\{" $jsonette]-$incr_indent-[regexp -all "\}" $jsonette]}] } return [join $output \n]XQL Not present: Generic, PostgreSQL, Oracle