message.getJSONArrayCount¶
Use when: You want to read values from the modified message during mapping. If you need the original incoming message, use source.getJSONArrayCount.
Signature: message.getJSONArrayCount(nodePath)
Returns: Integer count - the count of elements in the array for the nodePath array
Finds the count of objects in the array that matches 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.) |
Example¶
// Example: Get the number of elements in a JSON array at a given path.
// Sample JSON message structure
message = qie.createJSONMessage(
'{"people":[{"name":"John","kids":["Harold","Mark","Don","Lou"]},{"name":"Sue","kids":["Jimmy"]}]}'
);
// Count elements in the array
var kidsCount = message.getJSONArrayCount("/people/[1]/kids/[]"); // 4