From 8e17752b5d3b1b9d4149528fddb05800b95772ff Mon Sep 17 00:00:00 2001 From: wenshao Date: Mon, 11 Dec 2017 15:27:40 +0800 Subject: [PATCH] add Feature.NonStringKeyAsString, for issue #1633 --- .../alibaba/fastjson/parser/DefaultJSONParser.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java b/src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java index 164487f5dc..4a26b06e26 100755 --- a/src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java +++ b/src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java @@ -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()); }