Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
add Feature.NonStringKeyAsString, for issue #1633
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Dec 11, 2017
1 parent 771e101 commit 8e17752
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,14 @@ public final Object parseObject(final Map object, Object fieldName) {
lexer.resetStringPosition();
lexer.scanNumber();
try {
if (lexer.token() == JSONToken.LITERAL_INT) {
key = lexer.integerValue();
} else {
key = lexer.decimalValue(true);
}
if (lexer.token() == JSONToken.LITERAL_INT) {
key = lexer.integerValue();
} else {
key = lexer.decimalValue(true);
}
if (lexer.isEnabled(Feature.NonStringKeyAsString)) {
key = key.toString();
}
} catch (NumberFormatException e) {
throw new JSONException("parse number key error" + lexer.info());
}
Expand Down

0 comments on commit 8e17752

Please sign in to comment.