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: String
  • short: 16-bit integer
  • int: 32-bit integer
  • long: 64-bit integer
  • float: 32-bit single-precision decimal
  • double: 64-bit single-precision decimal
  • bool: Boolean
  • ipv4: IPv4 address
  • ipv6: IPv6 address
  • date: Date
  • map: Map
  • null: 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"