JSON_SERIALIZE
Syntax
Purpose
The json_serialize
function takes JSON data of any SQL data type as input and returns a textual representation of it. It is typically used to transform the result of a query and supports an error clause and a returning clause.
target_expr
The target_expr
is the input expression representing JSON data that is evaluated to produce JSON values. The input JSON value can be JSON text, OSON binary, or BSON binary. These values are serialized to produce textual output.
JSON_query_returning_clause
The JSON_query_returning_clause
specifies the return type of the function. The default return type is BLOB
. If the return type is RAW
or BLOB
, it contains UTF8
encoded JSON text.
PRETTY
The PRETTY
keyword specifies that the result should be formatted for human readability.
ASCII
The ASCII
keyword specifies that non-ASCII characters should be output using JSON escape sequences.
TRUNCATE
The TRUNCATE
keyword specifies that the result document should be truncated to fit in the specified return type.
JSON_query_on_error_clause
The JSON_on_error_clause
optionally controls the handling of errors that occur during the processing.
EMPTY ON ERROR
is not supported.