I am having a JsonNode response ( unirest ) which I want to parse using JSON Parser.
Now, let's say the structure is somewhat like this :
{
"expand" : "names",
"customfield_1" : null,
"customfield_2" : [ { "email":"[email protected]"},{...}]
}
So, the problem is that customfield_1 is a JsonArray and sometimes it can be null.
So, as soon as I use
JSONArray myArr = myObj.getJSONArray("customfield_1")
I get the following error:
org.json.JSONException: JSONObject["customfield_1"] is not a JSONArray.
I tried to change to JsonObject and JsonString but they also didn't help. How to avoid it ?