We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
希望num2类型的数值在转json的时候可以类似num3直接去掉后面多余的0
public void testJson() { JSONObject jsonObject = new JSONObject(); jsonObject.put("num1",12.1000); jsonObject.put("num2",new BigDecimal("12.1000")); jsonObject.put("num3",new BigDecimal("12.1000").stripTrailingZeros()); System.err.println(JSON.toJSONString(jsonObject, JSONWriter.Feature.WriteNonStringValueAsString, JSONWriter.Feature.WriteNullListAsEmpty, JSONWriter.Feature.WriteMapNullValue, JSONWriter.Feature.WriteNullNumberAsZero, JSONWriter.Feature.WriteBigDecimalAsPlain)); }
目前输出结果:{"num1":"12.1","num2":"12.1000","num3":"12.1"} 期望结果:{"num1":"12.1","num2":"12.1","num3":"12.1"}
The text was updated successfully, but these errors were encountered:
alibaba#4486: Remove Trailing zeros for decimals/float
35b3ab9
Create a PR for this
Sorry, something went wrong.
去掉WriteBigDecimalAsPlain试试?
WriteBigDecimalAsPlain
No branches or pull requests
希望num2类型的数值在转json的时候可以类似num3直接去掉后面多余的0
目前输出结果:{"num1":"12.1","num2":"12.1000","num3":"12.1"}
期望结果:{"num1":"12.1","num2":"12.1","num3":"12.1"}
The text was updated successfully, but these errors were encountered: