I’m using the json.org library to parse my json. But I have a field called “messages” that depending on the number of messages may come as a null field, a JSONObject (if there is only one message) or a JSONArray if there are multiple messages. I’m having some trouble to treat this because I have to read it using the correct object type as it will return an error if i don’t make it right. Oh, and it’s java.
Can anyone help me? I’m sure there is a “standart” way to treat this!
Assuming you’re using JSONTokener:
See http://www.json.org/javadoc/org/json/JSONTokener.html#nextValue%28%29 for all the other types that can be returned from
nextValue().