message.removeFromJSONArray¶
Signature: message.removeFromJSONArray(nodePath, index)
Returns: void
Removes the index from the JSON array nodePath.
Note
This method only applies to JSON formatted messages.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String | nodePath | the node path (XPath, HPath, Column ID, etc.) | |
| Integer | index | the index position in the array to remove. This is a 1 based index, so the first item is 1. |
Example¶
/* Sample JSON message structure */
message = qie.createJSONMessage(JSON.stringify(
[
{"name": "testing1", "description": "testing1desc"},
{"name": "testing2", "description": "testing2desc"},
{"name": "testing3", "description": "testing3desc"}
]
));
// remove the "testing2" object from the array
message.removeFromJSONArray('/[]', 2);
/* Resulting JSON message structure */
// [
// {"name": "testing1", "description": "testing1desc"},
// {"name": "testing3", "description": "testing3desc"}
// ]