Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ClassCastException: org.json.simple.JSONObject cannot be cast to org.json.simple.JSONArray #10

Closed
GoogleCodeExporter opened this issue May 31, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

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/q5
71575199_2451.jpg","profile_url":"http://www.facebook.com/profile.php?id=5715751
99"}}

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.

Original issue reported on code.google.com by lamka...@gmail.com on 6 Nov 2009 at 10:54

@GoogleCodeExporter
Copy link
Author

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;

Original comment by lamka...@gmail.com on 6 Nov 2009 at 10:57

@GoogleCodeExporter
Copy link
Author

From the input you provided, this is a JSONObject and the code should likes 
like:

JSONObject user_obj=(JSONObject)user_obj;

Original comment by fangyid...@gmail.com on 8 Nov 2009 at 10:24

  • Changed state: Invalid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant