The table below lists all the
json built-in
functions (in this namespace:
http://marklogic.com/xdmp/json
).
You can also view these functions broken down by category:
This is the JSON module used for customized tranformation from XML to and from JSON.
To use the JSON module as part of your own XQuery module, include the following line in your XQuery prolog:
import module namespace json = "http://marklogic.com/xdmp/json"
at "/MarkLogic/json/json.xqy";
The JSON module employs a concept of 'strategies'. Strategies are different methods of transforming XML to JSON or JSON to XML. Different strategies tackle different use cases.
The basic
strategy is used by the REST API and
handles the use case of transforming arbitrary JSON into a
fixed XML structure which is designed to be efficiently
stored and indexed in MarkLogic.
The basic
strategy is semantically
roundtrippable from JSON to XML back to JSON. The
basic
strategy is
used when no configuration object is specified.
The full
strategy targets the opposite use case
as the default (basic
) strategy.
The full
strategy
takes arbitrary XML and produces a fixed JSON structure
which preserves most of the semantics of the XML
document.
The custom
strategy allows customization of the
JSON and XML transformation and produces more reasonable
looking XML or JSON at the expense of supporting a
smaller subset of XML document structures.
See also the xdmp:from-json and xdmp:to-json functions.
Function name | Description |
---|---|
json:array | Creates a (JSON) array, which is like a sequence of values, but allows for nesting. |
json:array-pop | Pop a value from the end of the array. |
json:array-push | Push a value to the end of the array, increasing the size of the array by one. |
json:array-resize | Resize the array to the new size. |
json:array-set-javascript-by-ref | If true is specified, sets a json:array to be passed to JavaScript by reference. |
json:array-size | Returns the size of the array. |
json:array-values | Returns the array values as an XQuery sequence. |
json:array-with | Push a value to the end of the array, increasing the size of the array by one. |
json:check-config | This function checks a json configuration object and returns a report. |
json:config | This function creates a configuration object for a specified strategy. |
json:null | Returns the JSON null value, which is an empty sequence to XQuery, but not a Sequence when passed to JavaScript. |
json:object | Creates a JSON object, which is a kind of map with a fixed and ordered set of keys. |
json:object-define | Creates a JSON object. |
json:set-item-at | Sets a value in an array at a specified position. |
json:subarray | Extract a subarray from an array, producing a new array. |
json:to-array | Constructs a json:array from a sequence of items. |
json:transform-from-json | This function transforms a JSON document to XML using the default ("basic") strategy. |
json:transform-to-json | This function transforms an XML document to JSON using the default ("basic") strategy if none is supplied. |
json:transform-to-json-object | This function transforms an XML document to JSON and returns an object. |
json:transform-to-json-xml | This function transforms an XML document to JSON and returns an xml element. |