diff --git a/src/main/java/com/alibaba/fastjson/JSON.java b/src/main/java/com/alibaba/fastjson/JSON.java index 6159c72b1b..58be1d984d 100644 --- a/src/main/java/com/alibaba/fastjson/JSON.java +++ b/src/main/java/com/alibaba/fastjson/JSON.java @@ -703,6 +703,12 @@ public static String toJSONString(Object object, int defaultFeatures, Serializer serializer.write(object); String outString = out.toString(); int len = outString.length(); + while (len > 0 + && outString.charAt(len - 1) == '0' + && object instanceof Number + && !out.isEnabled(SerializerFeature.WriteClassName)) { + len--; + } if (len > 0 && outString.charAt(len -1) == '.' && object instanceof Number