Skip to content

message.setAllJSONArrays

Signature: message.setAllJSONArrays(nodePath)

Returns: void

Find all nodes that match nodePath and set each node to an empty array '[]'.

Note

This method only applies to JSON-formatted messages.

Parameters

Type Name Description Default
String nodePath the node path (XPath, HPath, Column ID, etc.)

Example

// Given a JSON message like:
message = qie.createJSONMessage(
    JSON.stringify(
        {
            "people": [
                {
                    "name": "David",
                    "age": 41,
                    "children": [
                        {"name": "Judy"},
                        {"name": "Michael"}
                    ]
                },
                {
                    "name": "Nathan",
                    "age": 38,
                    "children": [
                        {"name": "Kaden"},
                        {"name": "Brie"}
                    ]
                }
            ]
        }
    )
);

// Set all matching array nodes to empty arrays
// (Here: clears each /people/*/children array)
message.setAllJSONArrays("/people/children");

// Resulting JSON:
// {
//     "people": [
//         { "name": "David",  "age": 41, "children": [] },
//         { "name": "Nathan", "age": 38, "children": [] }
//     ]
// }