} else {
result = new OrderedJSONObject();
}
}
if (lastToken != Token.TokenBraceL) throw new JSONException("Expecting '{' " + tokenizer.onLineCol() + " instead, obtained token: '" + lastToken + "'");
lastToken = tokenizer.next();
while (true) {
if (lastToken == Token.TokenEOF) throw new JSONException("Unterminated object " + tokenizer.onLineCol());
if (lastToken == Token.TokenBraceR) {
lastToken = tokenizer.next();
break;
}
if (!lastToken.isString()) throw new JSONException("Expecting string key " + tokenizer.onLineCol());
String key = lastToken.getString();
lastToken = tokenizer.next();
if (lastToken != Token.TokenColon) throw new JSONException("Expecting colon " + tokenizer.onLineCol());
lastToken = tokenizer.next();
Object val = parseValue(ordered);
result.put(key, val);
if (lastToken == Token.TokenComma) {
lastToken = tokenizer.next();
}
else if (lastToken != Token.TokenBraceR) {
throw new JSONException("expecting either ',' or '}' " + tokenizer.onLineCol());
}
}
return result;
} catch (IOException iox) {
JSONException jex = new JSONException("Error occurred during object input read.");
jex.initCause(iox);
throw jex;
}
}