beetlebug▾
/

ztcl::json number

Writes a JSON number.

ztcl::json number N

Description

Gives N as a JSON number. N must be a number of Tcl, and Inf and NaN are errors.

Arguments

ArgumentTypeDefaultDescription
NnumberrequiredThe number.

Returns

The JSON text.

Examples

Each example of this page runs after package require ztcl::json.

% ztcl::json number 1.5
1.5

Errors

% ztcl::json number x
expected a number but got "x"
-errorcode ZT JSON VALUE

% ztcl::json number inf
json has no number "inf"
-errorcode ZT JSON VALUE

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also