... |
{code:SQL}JSONARRAY(value...){code} |
value is any object [convertable to a JSON|#Conversion to JSON] value. Return value is a clob marked as being valid JSON. |
Null values will be included in the result as null literals. |
... |
{code} |
h1. JSONOBJECT Returns a JSON object. {code:SQL}JSONARRAY(value [as name] ...){code} value is any object [convertable to a JSON|#Conversion to JSON] value. Return value is a clob marked as being valid JSON. Null values will be included in the result as null literals. If a name is not supplied and the expression is a column reference, the column name will be used otherwise exprN will be used where N is the 1-based index of the value in the JSONARRAY expression. {code:sql title=mixed value example} jsonObject('a"b' as val, 1, null as "null") {code}Would return{code} {"val":"a\"b","expr2":1,"null":null} {code} |
h1. JSONPARSE |
... |
{code:SQL}JSONPARSE(value, wellformed){code} |
value is blob with an appropriate JSON binary encoding (UTF-8, UTF-16, or UTF-32) or a clob. wellformed is a boolean indicating that validation should be skipped. Return value is a clob marked as being valid JSON. |
A null for either input will return null. |
... |
JSON functions provide functionality for working with JSON (Javascript Object Notation) data.
Returns an xml document from JSON.
JSONTOXML(rootElementName, json)
rootElementName is a string, json is in {clob, blob}. Return value is xml.
The appropriate UTF encoding (8, 16LE. 16BE, 32LE, 32BE) will be detected for JSON blobs. If another encoding is used, see the to_chars function.
The result is always a well-formed XML document.
The mapping to XML uses the following rules:
JSON:
{"firstName" : "John" , "children" : [ "Randy", "Judy" ]}
XML:
<?xml version="1.0" ?> <person> <firstName>John</firstName> <children>Randy</children> <children>Judy<children> </person>
JSON:
[{"firstName" : "George" }, { "firstName" : "Jerry" }]
XML (Notice there is an extra "person" wrapping element to keep the XML well-formed):
<?xml version="1.0" ?> <person> <person> <firstName>George</firstName> </person> <person> <firstName>Jerry</firstName> </person> </person>
JSON:
{"/invalid" : "abc" }
XML:
<?xml version="1.0" ?> <root> <_u002F_invalid>abc</_u002F_invalid> </root>
Returns a JSON array.
JSONARRAY(value...)
value is any object convertable to a JSON value. Return value is a clob marked as being valid JSON.
Null values will be included in the result as null literals.
jsonArray('a"b', 1, null, false, {d'2010-11-21'})
["a\"b",1,null,false,"2010-11-21"]
Returns a JSON object.
JSONARRAY(value [as name] ...)
value is any object convertable to a JSON value. Return value is a clob marked as being valid JSON.
Null values will be included in the result as null literals.
If a name is not supplied and the expression is a column reference, the column name will be used otherwise exprN will be used where N is the 1-based index of the value in the JSONARRAY expression.
jsonObject('a"b' as val, 1, null as "null")
{"val":"a\"b","expr2":1,"null":null}
Validates and returns a JSON result.
JSONPARSE(value, wellformed)
value is blob with an appropriate JSON binary encoding (UTF-8, UTF-16, or UTF-32) or a clob. wellformed is a boolean indicating that validation should be skipped. Return value is a clob marked as being valid JSON.
A null for either input will return null.
jsonParse('"a"')
A straight-forward specification compliant conversion is used for converting values into their appropriate JSON document form.