You are viewing documentation about an older version (1.12.1). View latest version

snowflake.snowpark.functions.check_json

snowflake.snowpark.functions.check_json(col: Union[Column, str]) Column[source]

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