message.addObjectToJSONArray¶
Signature: message.addObjectToJSONArray(nodePath, value)
Returns: void
Find the first ArrayNode that matches nodePath and adds this value to the array.
Note
The value is of type 'Object' and not 'String' making this call type-aware.
Note
This method only applies to JSON-formatted messages.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String | nodePath | the node path (XPath, HPath, Column ID, etc.) | |
| Object | value | the new node value |
Example¶
// Given a JSON message like:
message = qie.createJSONMessage(
JSON.stringify(
{
"name": "Glenn",
"age": 41,
"children": []
}
)
);
// Add an object to the JSON array
message.addObjectToJSONArray(
"/children", // nodePath to the JSON array
'{"name":"Todd","age":17}' // object to append
);
// Resulting JSON:
// {
// "name": "Glenn",
// "age": 41,
// "children": [
// {
// "name": "Todd",
// "age": 17
// }
// ]
// }