Start of change

BSON_TO_JSON

The BSON_TO_JSON function converts a string containing formatted BSON data to a character string containing the data formatted as JSON.

Read syntax diagramSkip visual syntax diagram BSON_TO_JSON ( JSON-expression )
JSON-expression

Specifies an expression that returns a binary string value. It must contain formatted BSON data.

Start of changeIf JSON-expression is a JSON object with a key name of SYSIBM_ROOT_ARRAY, the key will be removed and the result will be the key's value.End of change

Start of changeIf JSON-expression contains duplicate keys, the duplicate keys are retained in the result JSON string.End of change

The data type of the result is CLOB(2G) with a CCSID of 1208.

If the argument can be null, the result can be null; if the argument is null, the result is the null value.

Note

If the outer JSON object's key is SYSIBM_ROOT_ARRAY, the key will be removed and the result will be the value of the key.

Example

  • Insert a value that contains data formatted as BSON into a column that holds JSON values.
    INSERT INTO TABLE1 (JSON_COLUMN) VALUES (BSON_TO_JSON(:BSON_DATA));
End of change