Running into a wall with a script that needs to parse a webhook payload. The goal is to check if a specific field exists inside a nested object, and if it does, assign the value to a script variable.
The incoming JSON looks like this:
{
"data": {
"user": {
"id": 12345,
"status": "active"
}
}
}
I’ve tried setting up an IF action to check for the existence of the status field using a regex match against the raw body, but that feels brittle. I want to use the ASSIGN action with the JSONExtract function directly.
My current ASSIGN setup:
- Variable:
temp_status - Value:
JSONExtract(data.user.status) - Condition: IF
data.user.status!= null
The script fails validation. It says the expression is invalid. I suspect the dot notation isn’t supported directly in the ASSIGN value field for nested objects without a wrapper function.
How do you properly reference data.user.status in an ASSIGN action? Or is the only way to dump the whole JSON into a string variable and parse it manually?
Also, the documentation for the IF action is sparse on how to handle null checks for JSON paths. Does IF (data.user.status == null) work or does it throw a runtime error if the path doesn’t exist?