GetType Method (JSONDATA)


10.8, PLBCMP GUI Only

 

The GetType method gets and returns the type for the JSON field value in a JSONDATA object that is found for the JSON key with the specified name. This method uses the following format:

 

 

[label]

{object}.GetType

[GIVING {return}] USING [*NAME=]{name}[:

 

 

[*INDEX1=]{index1}][:

 

 

[*INDEX2=]{index2}][:

 

 

[*INDEX3=]{index3}]

 

Where:

label

Optional. A Program Execution Label.

object

Required. A JSONDATA object previously declared.

return

Optional. A Numeric Variable that returns a JSON value type for the JSON field specified by the name parameter.

name

Required. A Character String Variable or literal that specifies a JSON field name for a JSONDATA object.

index1

Optional. A Numeric Variable, decimal number, or Numeric expression that defines the first index of a JSON array that is being accessed.

index2

Optional. A Numeric Variable, decimal number, or Numeric expression that defines the second index of a JSON multi-dimensioned array that is being accessed.

index3

Optional. A Numeric Variable, decimal number, or Numeric expression that defines the third index of a JSON multi-dimensioned array that is being accessed.

Flags Affected: EOS, OVER, ZERO

Notes:

 

  1. The EOS flag is always cleared.

  2. The ZERO flag is set if the return value is zero. Otherwise, the ZERO flag is cleared for non-zero values.

  3. The OVER flag is set if the return value must be truncated.

  4. At runtime, the tokens $1, $2, and $3 that appear in the {name} parameter are replaced with the numeric values of the corresponding {index1}, {index2}, or {index3} parameters.

  5. The {return} values are determined by the JSON field value type being accessed using a JSON field key specified by the {name} parameter. The JSON field value types are defined as follows:

  6.  

    Return Value

    Type

    $JSF_TYPE_OBJECT (1)

    This is a json_object type.

    $JSF_TYPE_ARRAY (2)

    This is a json_array type.

    $JSF_TYPE_INTEGER (3)

    This is a json_integer type.

    $JSF_TYPE_DOUBLE (4)

    This is a json_double type.

    $JSF_TYPE_STRING (5)

    This is a json_string type.

    $JSF_TYPE_BOOLEAN (6)

    This is a json_boolean type.

    $JSF_TYPE_NULL (7)

    This is a json_null type.

     

  7. If an error occurs, the JSONDATA object method 'SyntaxError' canbe used to retrieve that last error that was generated.

 

 

See Also: Method Syntax, JSONDATA Methods



PL/B Language Reference