diff --git a/core/src/main/java/com/alibaba/fastjson2/JSONReader.java b/core/src/main/java/com/alibaba/fastjson2/JSONReader.java index 5e78db9be7..bfee9d411f 100644 --- a/core/src/main/java/com/alibaba/fastjson2/JSONReader.java +++ b/core/src/main/java/com/alibaba/fastjson2/JSONReader.java @@ -2977,6 +2977,10 @@ public final Number getNumber() { decimalStr + "E" + exponent); } + if ((context.features & Feature.UseDoubleForDecimals.mask) != 0) { + return decimal.doubleValue(); + } + return decimal; } case JSON_TYPE_BIG_DEC: { @@ -4562,8 +4566,14 @@ public enum Feature { /** * Feature that disables the support for single quote. + * @since 2.0.53 + */ + DisableSingleQuote(1L << 31L), + + /** + * @since 2.0.53 */ - DisableSingleQuote(1 << 31); + UseDoubleForDecimals(1L << 32L); public final long mask; diff --git a/fastjson1-compatible/src/main/java/com/alibaba/fastjson/parser/JSONScanner.java b/fastjson1-compatible/src/main/java/com/alibaba/fastjson/parser/JSONScanner.java index 3328a3e3fe..9f11576468 100644 --- a/fastjson1-compatible/src/main/java/com/alibaba/fastjson/parser/JSONScanner.java +++ b/fastjson1-compatible/src/main/java/com/alibaba/fastjson/parser/JSONScanner.java @@ -113,7 +113,7 @@ public void config(Feature feature, boolean state) { rawFeature = JSONReader.Feature.UseNativeObject; break; case UseBigDecimal: - rawFeature = JSONReader.Feature.UseBigDecimalForDoubles; + rawFeature = JSONReader.Feature.UseDoubleForDecimals; not = true; break; case OrderedField: @@ -166,7 +166,7 @@ public boolean isEnabled(Feature feature) { rawFeature = JSONReader.Feature.UseNativeObject; break; case UseBigDecimal: - return !reader.isEnabled(JSONReader.Feature.UseBigDecimalForDoubles); + return !reader.isEnabled(JSONReader.Feature.UseDoubleForDecimals); default: break; }