ES|QL JSON_STRING function

Builds a JSON object string from key/value pairs.

Embedded
key
The key of the first key/value pair.
value

The value of the first pair, followed by any further alternating keys and values. Provide arguments as alternating key/value pairs.

Builds a JSON object string from one or more key/value pairs. Keys must be strings. Numbers and booleans are rendered as JSON primitives, all other values are rendered as JSON strings. A multi-valued value is rendered as a JSON array and a null value as JSON null.

key value result
keyword boolean keyword
keyword date keyword
keyword date_nanos keyword
keyword double keyword
keyword integer keyword
keyword ip keyword
keyword keyword keyword
keyword long keyword
keyword text keyword
keyword unsigned_long keyword
keyword version keyword
text boolean keyword
text date keyword
text date_nanos keyword
text double keyword
text integer keyword
text ip keyword
text keyword keyword
text long keyword
text text keyword
text unsigned_long keyword
text version keyword
ROW name = "Sydney", population = 5312163
| EVAL doc = JSON_STRING("city", name, "population", population)
		
doc:keyword
{"city":"Sydney","population":5312163}