New issue 10 by lamkampo: java.lang.ClassCastException:
org.json.simple.JSONObject cannot be cast to org.json.simple.JSONArray
http://code.google.com/p/json-simple/issues/detail?id=10
Hi there
I'm new to json-simple, tried to use it to decode a json string that
encoded by PHP(it was 2-dimension array in PHP) json_encode, the string
looks like
{"User_001":{"first_name":"xxx","last_name":"xxx","name":"xxx
xxx","uid":"1571575199","pic_square":"http://profile.ak.fbcdn.net/v230/639/72/q571575199_2451.jpg","profile_url":"http://www.facebook.com/profile.php?id=571575199"}}
but it reports error at run time:
java.lang.ClassCastException: org.json.simple.JSONObject cannot be cast to
org.json.simple.JSONArray
any idea why? thanks for any help.
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
forgot to include the java code. here it is.
Object user = win.eval("get_user_info()"); // get JSON from javascript
Object user_obj=JSONValue.parse(user.toString());
JSONArray user_array=(JSONArray)user_obj;
Comment #2 on issue 10 by fangyidong: java.lang.ClassCastException:
org.json.simple.JSONObject cannot be cast to org.json.simple.JSONArray
http://code.google.com/p/json-simple/issues/detail?id=10
From the input you provided, this is a JSONObject and the code should likes
like:
JSONObject user_obj=(JSONObject)user_obj;