Hello Guys!
Can you please tell me if there is an option to check if JSON string contains required attribute?
The problem: we have a JSON String. Some attributes are optional.
In the JSON Parser element (which retrieve items from JSON String) I do not see such option.
So, from time to time I catch an exception like
30/08/2022 17:17:02:196 INFO - E8495272229B60B9B49A564B5AECDD1E:/MyApp: Capturing exception [com.avaya.sce.runtimecommon.SCERuntimeException]. Message [ERROR : Could not Parse JSON : org.json.JSONException: JSONObject["PROPERTY"] not found.org.json.JSONException: JSONObject["PROPERTY"] not found.
**** Root Cause
org.json.JSONException: JSONObject["PROPERTY"] not found.
at org.json.JSONObject.get(JSONObject.java:454)
at com.avaya.sce.pdc.json.operations.JSONParser.execute(JSONParser.java:137)
at com.avaya.sce.runtime.Data.evaluateActions(Data.java:237)
Even if I put JSON Parser element in
try{}
catch(*) I still see such exception in the trace log file.
Of cause we can use custom java code and jackson or gson lib, but it is quite convenient to use built-in JSON Parser in Data items.
Thanks in advance for you help!
Vasily.
|