ztcl::json valid
Tests whether a text is valid JSON.
ztcl::json valid TEXT
Description
Gives 1 when TEXT is one valid JSON value of RFC 8259, with optional white space around it, else 0. The numbers 1. and .1 are not valid.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| TEXT | string | required | The text to test. |
Returns
1 or 0.
Examples
Each example of this page runs after package require ztcl::json.
% ztcl::json valid {{"a": 1}}
1
% ztcl::json valid {[1,}
0
% ztcl::json valid {1.}
0
Errors
% ztcl::json valid
wrong # args: should be "ztcl::json valid text"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1