Type-Testing Methods
Each type-testing method resolves the node identified by this-node and sets an output flag to 1 if the node matches the described type, or 0. The methods return an INTEGER of 0 upon successful completion or nonzero if the node ID cannot be resolved.
The common syntax for the type-testing methods is:
These are the required arguments for the type-testing methods.
|
Property |
Value |
|---|---|
|
Direction |
Input |
|
Data Type |
BIGINT |
|
Description |
Node ID to test. Passing a null or invalid node ID causes the method to return a nonzero error code. |
|
Property |
Value |
|---|---|
|
Direction |
Output |
|
Data Type |
INTEGER |
|
Description |
Set to 1 if the type matches otherwise set to 0. |
|
Method |
Sets is-flag to 1 when the node is: |
|---|---|
|
ISOBJECT |
a JSON object (`{…}`) |
|
ISARRAY |
a JSON array (`[…]`) |
|
ISSTRING |
a JSON string, including an empty string. |
|
ISINT |
a JSON integer (a number with no decimal point or exponent). |
|
ISFLOAT |
A JSON floating-point number that contains a . or exponent. |
|
ISNUMBER |
a numeric type, integer or floating-point number. |
|
ISBOOLTRUE |
the JSON literal, true. |
|
ISBOOLFALSE |
the JSON literal, false. |
|
ISBOOL |
true or false. |
|
ISNULL |
the JSON literal, null. |
This example demonstrates the functionality of the type-testing methods.
dcl int rc rc1;
dcl bigint nodeid;
rc = jst.findNode(rootid, '["scores"][0]', nodeid);
rc1 = jst.isNumber(nodeid, rc);
if rc = 1 then put 'First score is a number';
rc1 = jst.isInt(nodeid, rc);
if rc = 1 then put 'First score is an integer';
rc1 = jst.isFloat(nodeid, rc);
if rc = 1 then put 'First score is a float';