typeof()
Returns a string indicating the type of the given expression.
Syntax
typeof(EXPR)
Required Parameter
EXPR
- Expression that returns a value to check the type.
Description
This returns the following strings depending on the data type.
string
: Stringshort
: 16-bit integerint
: 32-bit integerlong
: 64-bit integerfloat
: 32-bit single-precision decimaldouble
: 64-bit single-precision decimalbool
: Booleanipv4
: IPv4 addressipv6
: IPv6 addressdate
: Datemap
: Mapnull
:null
Usage
json "{}" | eval type=typeof(null) => null
json "{}" | eval type=typeof("sample") => "string"
json "{}" | eval type=typeof(1) => "int"
json "{}" | eval type=typeof(2147483648) => "long"
json "{}" | eval type=typeof(1.2) => "double"
json "{}" | eval type=typeof(ip("1.2.3.4")) => "ipv4"
json "{}" | eval type=typeof(ip("::1")) => "ipv6"
json "{}" | eval type=typeof(true) => "bool"