The constructor JSONArray(Object[]) is undefined

That constructor is only available from API19: JSONArray(Object array)

Therefore the most likely explanation is you are compiling against a lower API level.

You can use the collection constructor though, by passing a list:

JSONArray arrayObj = obj instanceof JSONArray
                      ? (JSONArray) obj
                      : new JSONArray(Arrays.asList(obj));

Leave a Comment