I am performing a JSONPATH transformation of an API answer. If the device is offline the json expression containts on error code which i am parsing with and it works
var String Anova_online = transform( "JSONPATH", "$.error.code" , Anova_Answer)
but when the device is online the path with error doesn’t exist and I get an error in the log
13:27:00.337 [ERROR] [core.transform.actions.Transformation] - Error executing the transformation ‘JSONPATH’: Invalid path ‘$.error.code’ in ‘{“status”:{“cooker_id”:“anova f56-a007e005da4”,“is_running”:true,“current_temp”:65.5,“target_temp”:65.5,“temp_unit”:“c”,“speaker_mode”:true,“current_job_id”:“5793c128-95a0-47d6-ae02-d8f524512da5”,“current_job”:{“job_id”:“5793c128-95a0-47d6-ae02-d8f524512da5”,“job_type”:“manual_cook”,“job_stage”:“maintaining”,“is_running”:true,“target_temp”:65.5,“temp_unit”:“c”,“job_start_time”:“2018-03-04T11:21:08.569504Z”,“job_update_time”:“2018-03-04T11:21:09.569505Z”,“max_circulation_interval”:300,“threshold_temp”:4.444444444444444,“job_info”:{“display_item_identifier”:“1520162467787”,“duration”:0,“job_type”:“manual_cook”,“source”:“3”,“temperature”:65.4,“temperature_unit”:“C”}},“is_timer_running”:false}}’
The docu says that the transformation should return null when the path doesn’t exist. What am I doing wrong?