pyflink.table.expressions.json_array#
- json_array(on_null: pyflink.table.expression.JsonOnNull = JsonOnNull.ABSENT, *args) pyflink.table.expression.Expression [source]#
Builds a JSON array string from a list of values.
This function returns a JSON string. The values can be arbitrary expressions. The on_null behavior defines how to treat NULL values.
Elements which are created from another JSON construction function call (json_object, json_array) are inserted directly rather than as a string. This allows building nested JSON structures.
Examples:
>>> json_array() # '[]' >>> json_array(JsonOnNull.NULL, 1, "2") # '[1,"2"]' >>> # Expressions as values >>> json_array(JsonOnNull.NULL, col("orderId")) >>> json_array(JsonOnNull.NULL, null_of(DataTypes.STRING())) # '[null]' >>> json_array(JsonOnNull.ABSENT, null_of(DataTypes.STRING())) # '[]' >>> json_array(JsonOnNull.NULL, json_array(JsonOnNull.NULL, 1)) # '[[1]]'
See also
New in version 1.12.0.