Skip to content

message.addStringToJSONArray

Signature: message.addStringToJSONArray(nodePath, value)

Returns: void

Find the first ArrayNode that matches nodePath and adds this value to the 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.)
String value the new node value

Example

// Given a JSON message like:
message = qie.createJSONMessage(
    JSON.stringify(
        {
            "name": "David",
            "favorite meals": [
                "Lasagna",
                "Pizza"
            ]
        }
    )
);

// Add a string value to the JSON array
message.addStringToJSONArray(
    "/favorite meals", // nodePath to the JSON array
    "Spaghetti"        // value to append
);

qie.debug(message);

// Resulting JSON:
// {
//     "name": "David",
//     "favorite meals": [
//         "Lasagna",
//         "Pizza",
//         "Spaghetti"
//   ]
// }