Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

When i try to convert a json string to a JSONObject, i got the following error.

java.lang.StackOverflowError
at org.json.JSONArray.<init>(JSONArray.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:322)
at org.json.JSONArray.<init>(JSONArray.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:322)
at org.json.JSONArray.<init>(JSONArray.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:322)
at org.json.JSONArray.<init>(JSONArray.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:322)
at org.json.JSONArray.<init>(JSONArray.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:322)
at org.json.JSONArray.<init>(JSONArray.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:322)
at org.json.JSONArray.<init>(JSONArray.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:322)
at org.json.JSONArray.<init>(JSONArray.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:322)
at org.json.JSONArray.<init>(JSONArray.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:322)
at org.json.JSONArray.<init>(JSONArray.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:322)
at org.json.JSONArray.<init>(JSONArray.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:322)
at org.json.JSONArray.<init>(JSONArray.java:116)

My code sample:

String jsonStr = "{\"node\":[";
JSONObject obj =  new JSONObject(jsonStr);

Then i found that, the error occurred due to the broken json string "{"node":[" was used.

My question is,

Is this an issue? If so how do i fix this issue?

What is the impact of this issue?

share|improve this question
    
It certainly looks like a bug in the org.json package; this JSON is outright illegal to begin with and should be reported as such – fge Jul 13 '15 at 10:50
    
try this String jsonStr = '{"node":"[....]"}'; JSONObject obj = new JSONObject(jsonStr); – Himanshu Chaudhary Jul 13 '15 at 12:05
    
@HimanshuChaudhary , yes i got the reason for that issue but i'm curious to know that how to fix it & what is the impact of the issue. – Selvakumar Jul 13 '15 at 12:30
    
@Selvakumar Hi, what is the org.json package you're using? – kucing_terbang Aug 10 '15 at 7:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.