message.setAllJSONStrings¶
Signature: message.setAllJSONStrings(nodePath, value)
Returns: void
Find all nodes that match nodePath and set each nodes value.
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(
{
"people": [
{ "name": "Tony", "loves": "cats" },
{ "name": "Mario", "loves": "dogs" },
{ "name": "Michaelangelo", "loves": "cats" }
]
}
)
);
// Replace all matching string values
message.setAllJSONStrings(
"/people/loves",
"" // set each 'loves' value to an empty string
);
// Resulting JSON:
// {
// "people": [
// { "name": "Tony", "loves": "" },
// { "name": "Mario", "loves": "" },
// { "name": "Michaelangelo", "loves": "" }
// ]
// }