JSON::set

Description

This command sets a JSON element (aka. JSON value) to the given type and given content, replacing any existing value. The given value should be according to the given type, as described below:
  • null: Omit. JSON type null has no value.
  • boolean: 0 (false) or 1 (true).
  • integer: A Tcl number representing an integer in the range -(2^63) through (2^63 - 1). Otherwise, use the literal type.
  • literal: A Tcl string not requiring JSON escape sequences.
  • string: A Tcl string without escape sequences (certain characters will be replaced by JSON escape sequences).
  • object: Omit. An empty object is created.
  • array: Omit. An empty array is created.

Syntax

JSON::set <JSON_ELEMENT> <JSON_TYPE> [JSON_VALUE]

Examples

when JSON_REQUEST {
    set rootval [JSON::root]
    JSON::set $rootval string HelloWorld
}