VARIANTΒΆ

Data type evaluated dynamically at runtime. VARIANT can represent any of the primitive data types.

Sometimes the type of an extracted data element is not known before the parser is run. For instance, JSON structures contain also the type of data that could be used for extraction. In this case, the parser uses the VARIANT type to capture extracted data elements.

Example Parsing Json object {"name":"John","age":33}:

1
JSON:person

will result in following extracted fields:

person[name] = "John" (VARIANT:STRING)
person[age] = 33 (VARIANT:LONG)

Note

that when using VARIANT data in functions you must cast the data into respective primitive types required by the function:

1
2
3
4
5
6
7
$jsonString = '{"name":"John","age":33}';

dual
| select(PARSE("JSON:person",$jsonString))
| select(STRLEN(STRING(person[name])),
         is_adult:LONG(person[age]) > 18)
;
where on line :
  1. the person[name] must be converted to STRING in submitting as an argument to STRLEN
  2. the person[age] must be converted to numerical type (for instance LONG) at the comparison