Skip to content

source.getJSONArrayCount

Use when: You want to read values from the original incoming message before any mapping changes. If you need the modified message during mapping, use message.getJSONArrayCount.

Signature: source.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

// Given a JSON source with nested arrays.
/* source:
{
    "people": [
        { "name": "John", "kids": ["Harold", "Mark", "Don", "Lou"] },
        { "name": "Sue",  "kids": ["Jimmy"] }
    ]
}
*/

// Retrieve the number of elements in the kids array for the 2nd person (1-based index).
var kidsCount = source.getJSONArrayCount('/people/[2]/kids/[]'); // expected: 1