Data 360 SQL and Tableau Hyper API
JSON
JSON_ARRAY
JSON_OBJECT
JSON_SCALAR
Type Conversions
Logical Operators
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
JSONApplies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Parses a string and interprets it as a JSON value, validating that the string is well-formed JSON.
1json(<string> [FORMAT JSON])You can also parse a string into JSON with a cast.
1<string>::json
2CAST(<string> AS json)
3TRY_CAST(<string> AS json)<string>: The string to parse as JSON. The string must be a valid JSON document.FORMAT JSON: Accepted for SQL-standard compatibility. It has no effect on the result.Returns a json value. Use the result to embed pre-formatted JSON into json_array or json_object, or wherever a json value is expected.
invalid JSON document error.<string>::json and CAST(<string> AS json) perform the same validation as the json constructor.TRY_CAST(<string> AS json) if you want to suppress validation errors.WITH UNIQUE KEYS option from the SQL-standard, which would reject objects with duplicate keys, isn’t supported.Interpret a string as a JSON value.
1SELECT json('{"a":1}') AS result;Returns {"a":1}.
A cast from a string performs the same validation.
1SELECT '[]'::json AS result;Returns [].
Use the constructor to embed an existing document without escaping it.
1SELECT json_object('a': 1, 'b': json('{"nested":true}')) AS result;Returns {"a":1,"b":{"nested":true}}.
Malformed input raises an error.
1SELECT json('{"a": invalid}');Raises an invalid JSON document error.
[JSON_ARRAY](./json-array.md) - Build a JSON array from a list of values.[JSON_OBJECT](./json-object.md) - Build a JSON object from key-value pairs.[JSON_SCALAR](./json-scalar.md) - Convert a scalar value to JSON.