Thursday, 15 January 2015

android - org.json.simple.JSONObject cannot be cast to org.json.JSONObject -



android - org.json.simple.JSONObject cannot be cast to org.json.JSONObject -

when run next code...

jsonobject jsonobject = null; jsonparser parser=new jsonparser(); // needs "json-simple" library seek { object obj = parser.parse(responsebody); jsonobject=(jsonobject)obj; } catch(exception ex) { log.v("test","exception1: " + ex.getmessage()); }

...at runtime see next in log output:

exception1: org.json.simple.jsonobject cannot cast org.json.jsonobject

i don't understand why.

you have imported wrong class. change

import org.json.jsonobject;

to

import org.json.simple.jsonobject;

android json

No comments:

Post a Comment