beetlebug▾
/

ztcl::json exists

Tests whether a path of a JSON text has a value.

ztcl::json exists TEXT ?STEP ...?

Description

Gives 1 when the path of STEP arguments has a value in TEXT, else 0, with the walk of get.

Arguments

ArgumentTypeDefaultDescription
TEXTJSON textrequiredThe text.
STEPkey or indexnoneA key of an object, or an index of an array.

Returns

1 or 0.

Examples

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

% ztcl::json exists {{"a": {"b": 1}}} a b
1

% ztcl::json exists {{"a": 1}} z
0

% ztcl::json exists {[1, 2]} 1
1

Errors

% ztcl::json exists
wrong # args: should be "ztcl::json exists text ?step ...?"
-errorcode TCL WRONGARGS

Facts

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

See also