snowflake.snowpark.functions.check_json

snowflake.snowpark.functions.check_json(col: Union[Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/functions.py#L5050-L5071)

Checks the validity of a JSON document. If the input string is a valid JSON document or a NULL (i.e. no error would occur when parsing the input string), the function returns NULL. In case of a JSON parsing error, the function returns a string that contains the error message.

Example:

>>> df = session.create_dataframe(["{'ValidKey1': 'ValidValue1'}", "{'Malformed -- missing val':}", None], schema=['a'])
>>> df.select(check_json(df.a)).show()
-----------------------
|"CHECK_JSON(""A"")"  |
-----------------------
|NULL                 |
|misplaced }, pos 29  |
|NULL                 |
-----------------------
Copy
语言: 中文