Skip to content Skip to sidebar Skip to footer

Json For Android 2.2 Not Working

I my application which I tested with emulator and phone Andorid 4.1 and Android 2.2. On Android 4.2 everything works ok also on emulator with API 17. But on 2.2 I get error: java.l

Solution 1:

{"PRODUCT":{"0":"1","1":"sdasd","2":"1","3":"image","4":"0","5":"0","6":"-1","7":"0","product_id":"1","name":"sdasd","person_id":"1","image":"image","alergen_id":"0","contain":"0","aditiv_id":"-1","tmpgrade":"0"}}

I don't see any array in your json , maybe your object graph changes sometimes?

Do a check before Casting:

Objectobject = newJSONTokener(jsonString).nextValue();
object = (objectinstanceofJSONArray) ? (JSONArray)object : (JSONObject)object ;

Solution 2:

You tried to use

JSONArray array = newJSONArray(jsonString);

or

JSONObjectobject = newJSONObject(jsonString);

instead of using

Objectobject = newJSONTokener(jsonString).nextValue()

Post a Comment for "Json For Android 2.2 Not Working"