I’m using a function to create a simple JSON object:
{
"notNull":"notNull",
"Null":null
}
I would like to create an IF node to check whether the “Null” key is actually null. I’ve seen other similar questions but they seem to be more focused on if the entire JSON object’s data is empty.
In practice, we will be receiving purchase information from a webhook, and sometimes we will receive a null value if an option is not selected, and I would like to perform a different flow in these instances.
Is there any way to check for null in the GUI? If not, what’s the proper way to go about this?
You would use an expression in the If node to check a specific property on the input data into the node. Here’s an example. Notice how the field in the condition is purple with a dashed border, that’s because I set to an expression. Click the field and you’ll see the expression editor and some possible intputs on the left side. You might need to execute the workflow first for the input data to show up as an option since by default the previous node will have no data.
It looks like in this flow, you’re setting the property as a string containing “null”, right? In my case I would need something that can check if a key’s value is of the JSON data type null, and not a string.
Then in that case I believe you should be able to change the second value of the If node to also be an expression and input {{null}}. I changed the example to use a function item node to output {"property":null} and it seems to be working: