if (lexer.token() == JSONToken.NULL) {
lexer.nextToken(JSONToken.COMMA);
return null;
}
ParseContext context = parser.getContext();
if (object != null) {
context = context.getParentContext();
}
ParseContext childContext = null;
try {
Map<String, Object> fieldValues = null;
if (lexer.token() == JSONToken.RBRACE) {
lexer.nextToken(JSONToken.COMMA);
if (object == null) {
object = createInstance(parser, type);
}
return (T) object;
}
if (lexer.token() == JSONToken.LBRACKET && lexer.isEnabled(Feature.SupportArrayToBean)) {
return deserialzeArrayMapping(parser, type, fieldName, object);
}
if (lexer.token() != JSONToken.LBRACE && lexer.token() != JSONToken.COMMA) {
StringBuffer buf = (new StringBuffer()) //
.append("syntax error, expect {, actual ") //
.append(lexer.tokenName()) //
.append(", pos ") //
.append(lexer.pos()) //
;
if (fieldName instanceof String) {
buf //
.append(", fieldName ") //
.append(fieldName);
}
throw new JSONException(buf.toString());
}
if (parser.getResolveStatus() == DefaultJSONParser.TypeNameRedirect) {
parser.setResolveStatus(DefaultJSONParser.NONE);
}
for (;;) {
String key = lexer.scanSymbol(parser.getSymbolTable());
if (key == null) {
if (lexer.token() == JSONToken.RBRACE) {
lexer.nextToken(JSONToken.COMMA);
break;
}
if (lexer.token() == JSONToken.COMMA) {
if (parser.isEnabled(Feature.AllowArbitraryCommas)) {
continue;
}
}
}
if ("$ref" == key) {
lexer.nextTokenWithColon(JSONToken.LITERAL_STRING);
if (lexer.token() == JSONToken.LITERAL_STRING) {
String ref = lexer.stringVal();
if ("@".equals(ref)) {
object = context.getObject();
} else if ("..".equals(ref)) {
ParseContext parentContext = context.getParentContext();
if (parentContext.getObject() != null) {
object = parentContext.getObject();
} else {
parser.addResolveTask(new ResolveTask(parentContext, ref));
parser.setResolveStatus(DefaultJSONParser.NeedToResolve);
}
} else if ("$".equals(ref)) {
ParseContext rootContext = context;
while (rootContext.getParentContext() != null) {
rootContext = rootContext.getParentContext();
}
if (rootContext.getObject() != null) {
object = rootContext.getObject();
} else {
parser.addResolveTask(new ResolveTask(rootContext, ref));
parser.setResolveStatus(DefaultJSONParser.NeedToResolve);
}
} else {