โ03-08-2023 07:56 AM - edited โ03-08-2023 07:59 AM
Has anyone had luck handling null values in a JavaScript Connector? I have tried all these below but the error remains "Cannot read properties of null (reading 'regulation')"
regulation = arrayValue.regulation
regulation = arrayValue.regulation || 0
regulation = arrayValue[0].regulation || 0
if(arrayValue.regulation === null){regulation = "null"} else {regulation = arrayValue.regulation}
if(arrayValue.regulation != null){regulation = arrayValue.regulation} else {regulation = "null"}
Solved! Go to Solution.
โ03-13-2023 06:27 AM - edited โ03-13-2023 06:44 AM
Found it! The JSON had spacing that was different than the sample file I was using. I realized that all these attempts at finding the correct path to the key were where I needed to focus. So I went back and looked more closely at the parse JSON Output and noticed the spaces in the Output that I had not placed in the sample document of JSON parse, which is why it kept resulting in 'undefined'. Added the spacing and it worked.
Thanks for your help
Jim
โ03-08-2023 10:23 AM
Is this an accurate representation of input_json? Not sure if Status is an object or an array.
[{
"FirstName": "Spider",
"LastName": "Man",
"EmployeeId": "123",
"Status": {
"Regulation": null
}
}]
โ03-08-2023 11:09 AM
Yes, minus a couple square brackets [].
[{
"LastName": "",
"FirstName": "",
"Message": null,
"Status": [
{
"Regulation": ""
}
]
}]
โ03-13-2023 10:18 AM
Hey Jim,
Here are a couple threads that might be helpful!
Cheers,
Mary