diff --git a/org/json/JSONObject.java b/org/json/JSONObject.java index 63fd51e..ee5f968 100644 --- a/org/json/JSONObject.java +++ b/org/json/JSONObject.java @@ -187,8 +187,7 @@ public JSONObject(JSONTokener x) throws JSONException { case '}': return; default: - x.back(); - key = x.nextValue().toString(); + key = x.nextSimpleValue(c).toString(); } /* diff --git a/org/json/JSONTokener.java b/org/json/JSONTokener.java index 784ae45..c5d0715 100644 --- a/org/json/JSONTokener.java +++ b/org/json/JSONTokener.java @@ -363,12 +363,8 @@ public String nextTo(String delimiters) throws JSONException { */ public Object nextValue() throws JSONException { char c = nextClean(); - String s; switch (c) { - case '"': - case '\'': - return nextString(c); case '{': back(); return new JSONObject(this); @@ -377,6 +373,17 @@ public Object nextValue() throws JSONException { back(); return new JSONArray(this); } + return nextSimpleValue(c); + } + + Object nextSimpleValue(char c) throws JSONException { + String s; + + switch (c) { + case '"': + case '\'': + return this.nextString(c); + } /* * Handle unquoted text. This could be the values true, false, or