Forum OpenACS Development: Re: JSON Array & objects

Collapse
2: Re: JSON Array & objects (response to 1)
Posted by Iuri Sampaio on
As JSON results may vary a lot, it seems there will be customization for every kind of result. Roughly, there will be a combination of "array sets" and "foreaches", which can be put into a recursive ad_proc.

Not sure if that will solve all cases, but at least it works for GoogleMapsAPI :: nearbies places.

Best wishes,


set parsed_result [util::json::parse $json]

array unset json_hash
array set json_hash [lindex $parsed_result 1]
array set json_hash $json_hash(results)
...

if {[info exists json_hash(_array_)]} {
set json_array $json_hash(_array_)
foreach array_elem $json_array {
set obj [lindex $array_elem 0]
set json_list [lindex $array_elem 1]

if {$obj eq "_array_" } {
# here it goes a recursive call
...
}
}
}