JSON::root¶
Description¶
This command gets the JSON element (aka. JSON value) at the root of a JSON cache’s tree. If a JSON cache handle
is supplied, returns the root element of that JSON cache instance. This is useful when a JSON profile is not being used.
Note
If the cache provided is empty (eg. newly created by ‘JSON::create’), creates an empty JSON element at the root and returns the element.
Examples¶
when JSON_REQUEST {
set rootval [JSON::root]
JSON::set $rootval string HelloWorld
set rendered [JSON::render $cache]
}
when HTTP_REQUEST_DATA {
set cache [JSON::create]
set rootval [JSON::root $cache]
JSON::set $rootval string HelloWorld
set rendered [JSON::render $cache]
}