Using ECMAScript with JSON objects
You might want to configure a guard condition for a JSON message. You can use a Function action and ECMAScript, which supports JSON objects.
If you need to extract data or count the number of children in a JSON message you can use the Function action. ECMAScript has built-in support for JSON objects.
If it is not possible to do what you need to do in the message editor, you can use a Function action to process the message payload.
Tag the text (String) node of the incoming message.
Convert it to a JSON object as follows:
var obj = JSON.parse(tags["text"]);
Refer to the data values.
- The first person's firstName:
obj.employees[0].firstName
- The third person's lastName:
obj.employees[2].lastName
- The number of employees:
obj.employees.length
For more information about the Function action, see Function.