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
序列化时,希望Feature.WriteNonStringValueAsString,对Number类型有一致的处理。
Number
项目中通常以BigDecimal取代double/float,因此序列化时,保持client端js对的number处理。
number
@Test public void testSingle() { // default Assertions.assertEquals("true", JSON.toJSONString(true)); Assertions.assertEquals("123", JSON.toJSONString(123)); Assertions.assertEquals("123", JSON.toJSONString(Integer.valueOf("123"))); Assertions.assertEquals("3.14", JSON.toJSONString(3.14)); Assertions.assertEquals("3.14", JSON.toJSONString(Double.valueOf("3.14"))); Assertions.assertEquals("3", JSON.toJSONString(new BigDecimal("3"))); Assertions.assertEquals("3.14", JSON.toJSONString(new BigDecimal("3.14"))); // as string Assertions.assertEquals("true", JSON.toJSONString(true, Feature.WriteNonStringValueAsString)); Assertions.assertEquals("\"123\"", JSON.toJSONString(123, Feature.WriteNonStringValueAsString)); Assertions.assertEquals("\"123\"", JSON.toJSONString(Integer.valueOf("123"), Feature.WriteNonStringValueAsString)); Assertions.assertEquals("\"3.14\"", JSON.toJSONString(3.14, Feature.WriteNonStringValueAsString)); Assertions.assertEquals("\"3.14\"", JSON.toJSONString(Double.valueOf("3.14"), Feature.WriteNonStringValueAsString)); // FIXME 期望是同Integer一致,得到`"3"`,而不是`3` Assertions.assertEquals("\"3\"", JSON.toJSONString(new BigDecimal("3"), Feature.WriteNonStringValueAsString)); // FIXME 期望是同Double一致,得到`"3.14"`,而不是`3.14` Assertions.assertEquals("\"3.14\"", JSON.toJSONString(new BigDecimal("3.14"), Feature.WriteNonStringValueAsString)); }
testcase中FIXME的assert通过。
The text was updated successfully, but these errors were encountered:
fix write string for BigInteger and BigDecimal for issue alibaba#1537 …
beb3c7a
…and npe for issue alibaba#1534
fix write string for BigInteger and BigDecimal for issue #1537 and np…
c0ee65c
…e for issue #1534
https://github.com/alibaba/fastjson2/releases/edit/2.0.34 问题已修复,请用新版本
Sorry, something went wrong.
⬆️ alibaba/fastjson2#1537
9f89128
3834ed0
Revert "⬆️ alibaba/fastjson2#1537"
1d8a588
This reverts commit 3834ed0.
No branches or pull requests
问题描述
序列化时,希望Feature.WriteNonStringValueAsString,对
Number
类型有一致的处理。项目中通常以BigDecimal取代double/float,因此序列化时,保持client端js对的
number
处理。环境信息
重现步骤
期待的正确结果
testcase中FIXME的assert通过。
The text was updated successfully, but these errors were encountered: