message.getJSONKeys¶
Use when: You want to read values from the modified message during mapping. If you need the original incoming message, use source.getJSONKeys.
Signature: message.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¶
// Example: Retrieve the keys for a JSON object at a given path.
// Sample JSON message structure
message = qie.createJSONMessage(JSON.stringify(
{
test: "Hello, world!",
status: "success",
timestamp: "2025-01-21T14:35:00Z"
}
));
// Get keys for the root JSON object
var jsonKeys = message.getJSONKeys("/"); // ["test", "status", "timestamp"]