beetlebug▾
/

ztcl::json string

Writes a JSON string.

ztcl::json string S

Description

Gives S as a JSON string in quotes, with the escapes that JSON needs, such as \" for a quote.

Arguments

ArgumentTypeDefaultDescription
SstringrequiredThe text.

Returns

The JSON text.

Examples

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

% ztcl::json string "a\"b"
"a\"b"

Errors

% ztcl::json string
wrong # args: should be "ztcl::json string s"
-errorcode TCL WRONGARGS

Facts

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

See also