JSON::get¶
Description¶
A JSON value can be one of many types. This command returns the value (content) of an element according to its
type, as described below:
- null : An empty Tcl list.
- boolean : 1 for true or 0 for false.
- integer : A Tcl number representing an integer in the range -(2^63) through (2^63 - 1).
- literal: A Tcl string not requiring JSON escape sequences.
- string : A Tcl string without escape sequences (having been replaced by the characters they represent).
- object : A JSON object handle.
- array : A JSON array handle.
If type is specified and the value is not of the specified type, an error will be triggered.
Syntax¶
JSON::get <JSON_ELEMENT> [JSON_TYPE]
JSON::get <JSON_ELEMENT> [JSON_TYPE]¶
- Returns the content held within the JSON element, according to the types listed in the above description.
Examples¶
when JSON_REQUEST {
set rootval [JSON::root]
set content [JSON::get $rootval integer]
log local0. "$content"
}