proc deparse {data} {
switch -regexp [lindex $data 0] {
- ^true|false|null$ { uplevel 1 return [lindex $data 0] }
- ^num|str|obj|list$ {}
+ ^true|false|null$ { lindex $data 0 }
+ ^num|str|obj|list$ { eval $data }
default { error [ concat "Invalid JSON type " [lindex $data 0 0] ] }
}
- eval $data
}
}
proc parse_str {} {
variable json
-puts $json
# like Text::Balanced except ugly (borrowed from tcvJSON's code)
set reStr {(?:(?:\")(?:[^\\\"]*(?:\\.[^\\\"]*)*)(?:\"))}
if {![regexp $reStr $json string]} {