in juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserSession.java [458:539]
private <K,V> Map<K,V> parseIntoMap2(ParserReader r, Map<K,V> m, ClassMeta<K> keyType,
ClassMeta<V> valueType, BeanPropertyMeta pMeta) throws IOException, ParseException, ExecutableException {
if (keyType == null)
keyType = (ClassMeta<K>)string();
int S0=0; // Looking for outer {
int S1=1; // Looking for attrName start.
int S3=3; // Found attrName end, looking for :.
int S4=4; // Found :, looking for valStart: { [ " ' LITERAL.
int S5=5; // Looking for , or }
int S6=6; // Found , looking for attr start.
skipCommentsAndSpace(r);
int state = S0;
String currAttr = null;
int c = 0;
while (c != -1) {
c = r.read();
if (state == S0) {
if (c == '{')
state = S1;
else
break;
} else if (state == S1) {
if (c == '}') {
return m;
} else if (isCommentOrWhitespace(c)) {
skipCommentsAndSpace(r.unread());
} else {
currAttr = parseFieldName(r.unread());
state = S3;
}
} else if (state == S3) {
if (c == ':')
state = S4;
} else if (state == S4) {
if (isCommentOrWhitespace(c)) {
skipCommentsAndSpace(r.unread());
} else {
K key = convertAttrToType(m, currAttr, keyType);
V value = parseAnything(valueType, r.unread(), m, pMeta);
setName(valueType, value, key);
m.put(key, value);
state = S5;
}
} else if (state == S5) {
if (c == ',') {
state = S6;
} else if (isCommentOrWhitespace(c)) {
skipCommentsAndSpace(r.unread());
} else if (c == '}') {
return m;
} else {
break;
}
} else if (state == S6) {
if (c == '}') {
break;
} else if (isCommentOrWhitespace(c)) {
skipCommentsAndSpace(r.unread());
} else {
currAttr = parseFieldName(r.unread());
state = S3;
}
}
}
if (state == S0)
throw new ParseException(this, "Expected '{' at beginning of JSON object.");
if (state == S1)
throw new ParseException(this, "Could not find attribute name on JSON object.");
if (state == S3)
throw new ParseException(this, "Could not find ':' following attribute name on JSON object.");
if (state == S4)
throw new ParseException(this, "Expected one of the following characters: {,[,',\",LITERAL.");
if (state == S5)
throw new ParseException(this, "Could not find '}' marking end of JSON object.");
if (state == S6)
throw new ParseException(this, "Unexpected '}' found in JSON object.");
return null; // Unreachable.
}