Skip to content

source.getJSONKeys

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.getJSONKeys.

Signature: source.getJSONKeys(nodePath)

Returns: String[] keys - an array of keys (or properties) for the nodePath object

Find the first node that matches nodePath and if the node is a JSON Object, will return a list of keys (or properties) for that object. If the node is not a JSON Object, then an empty array will be returned.

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 object at the root.
/* source:
{
    "test": "Hello, world!",
    "status": "success",
    "timestamp": "2025-01-21T14:35:00Z"
}
*/

// Retrieve the keys (properties) for the JSON object at nodePath.
var keys = source.getJSONKeys('/'); // expected: ["test", "status", "timestamp"]