pyflink.table.expression.Expression.is_json#
- Expression.is_json(json_type: Optional[pyflink.table.expression.JsonType] = None) pyflink.table.expression.Expression[bool] [source]#
Determine whether a given string is valid JSON.
Specifying the optional json_type argument puts a constraint on which type of JSON object is allowed. If the string is valid JSON, but not that type, false is returned. The default is JsonType.VALUE.
Examples:
>>> lit('1').is_json() # True >>> lit('[]').is_json() # True >>> lit('{}').is_json() # True >>> lit('"abc"').is_json() # True >>> lit('abc').is_json() # False >>> null_of(DataTypes.STRING()).is_json() # False >>> lit('1').is_json(JsonType.SCALAR) # True >>> lit('1').is_json(JsonType.ARRAY) # False >>> lit('1').is_json(JsonType.OBJECT) # False >>> lit('{}').is_json(JsonType.SCALAR) # False >>> lit('{}').is_json(JsonType.ARRAY) # False >>> lit('{}').is_json(JsonType.OBJECT) # True
New in version 1.12.0.