I am parsing a json file and assigning the values from the json file to different parameters.
However, I am getting this error when accessing a nested object/parameter that doesn't exist
"TypeError: Cannot read property 'Record Data' of undefined"
I am accessing/saving them to diff parameters using something like this:
data[fileType][category]['parameterName1'] = obj[fileType][index][category]['Template 1']['1234']['Record Data']['key1']
data[fileType][category]['parameterName2'] = obj[fileType][index][category]['Template 2']['key2']
There are hundreds of parameters I need to parse and assign to parameters and some objects/parameters are optional so they will not be always in the json file. Also, please note that parameters have varying deepness. Some others are objects within objects and some are just normal parameters/properties.
So.. Is there a way for me to check if a certain parameter exists before actually assigning its value to a local parameter? Please note that I am dealing with hundreds of params so I am hoping that the implementation is cleanest possible.