-
-
Notifications
You must be signed in to change notification settings - Fork 249
JSON API draft
In order to provide JSON-nodes within Sirix we need a node-transaction API similar to the XdmNodeReadTrx/XdmNodeWriteTrx-API for XML.
The JSON-resource is also bootstrapped with a DocumentRootNode.
JSONNodeWriteTrx:
-
insertString(String)
creates a String node and moves the cursor to the created node -
insertBoolean(boolean)
creates a boolean node and moves the cursor to the created node -
insertNull()
creates a null node and moves the cursor to the created node insertNumber(int)
All of these can have a right sibling in case they are used in arrays, when used as object values they don't have a right sibling.
-
insertObject()
creates an empty object node and moves the node cursor to the created object node. Inserts the new nodeKey from the inserted object into the parent or the "left-sibling" node, even if there's no order among children in JSON. Otherwise a potential parent would grow and grow (which is always going to be copied).
Key (when the cursor is on an object-node the only valid method is):
-
insertObjectKey(String)
creates an object-key node and moves the node cursor to the created object-key node
Value (when the cursor is on an object-key the valid methods are and the node keys are inserted into the object key node):
-
insertString(String)
creates a String node -
insertBoolean(boolean)
creates a boolean node -
insertNumber(int)
creates a number node -
insertNull()
creates a null node insertObject()
-
insertArray()
creates an empty array and moves the node cursor to the created array node
On an array the above methods are valid. Once on another node within an array, the following methods are valid:
-
insertStringAsRightSibling(String)
-
insertBooleanAsRightSibling(boolean)
-
insertNullAsRightSibling(null)
-
insertNumberAsRightSibling(int)
-
insertObjectAsRightSibling()
-
insertArrayAsRightSibling()
-
insertString(String)
creates a String node -
insertBoolean(boolean)
creates a boolean node -
insertNull()
creates a null node
JSONNodeReadTrx:
moveTo(long)
, moveToObjectKey(long)
, moveToObjectValue(long)