if {[llength $args] > 0} {
set indent [lindex $args 0]
+ if {[llength $args] > 1} {
+ set indentIncr [lindex $args 1]
+ } else {
+ set indentIncr $indent
+ }
}
switch -- $type {
append output "\[\n[string repeat " " $indent]"
set tmp {}
foreach element [lrange $thing 1 end] {
- lappend tmp [unparse $element [expr {$indent + $indentIncr}]]
+ lappend tmp [unparse $element [expr {$indent + $indentIncr}] $indentIncr]
}
append output [join $tmp ",\n[string repeat " " $indent]"]
append output "\n[string repeat " " [expr {$indent - $indentIncr}]]\]"
for {set i 1} {$i < [llength $thing]} {incr i} {
set key [lindex $thing $i]
set value [lindex $thing [incr i]]
- lappend tmp "\"$key\": [unparse $value [expr {$indent + $indentIncr}]]"
+ lappend tmp "\"$key\": [unparse $value [expr {$indent + $indentIncr}] $indentIncr]"
}
append output [join $tmp ",\n[string repeat " " $indent]"]
append output "\n[string repeat " " [expr {$indent - $indentIncr}]]\}"