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? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
@Test public void testNumber() { NumberTest test = new NumberTest(); test.setNum(10L); test.setTime(new Date()); test.setDecimal(new BigDecimal("0.02")); JSONObject jsonObject = (JSONObject) JSON.toJSON(test); assert Long.class == jsonObject.get("num").getClass(); assert Date.class == jsonObject.get("time").getClass(); assert BigDecimal.class == jsonObject.get("decimal").getClass(); } static class NumberTest { private Long num; private Date time; private BigDecimal decimal; public Long getNum() { return num; } public void setNum(Long num) { this.num = num; } public Date getTime() { return time; } public void setTime(Date time) { this.time = time; } public BigDecimal getDecimal() { return decimal; } public void setDecimal(BigDecimal decimal) { this.decimal = decimal; } }
请填写以下信息:
以上代码使用 Fastjson 1.2.83可以通过测试用例 使用Fastjson 2.0.49无法通过测试用例 经查是因为转换为JSONObject对象时,类型发生了变化
测试用例能够通过 下图为Fastjson 1.2.83测试结果
The text was updated successfully, but these errors were encountered:
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.50-SNAPSHOT/ 已经支持,请帮忙用2.0.50-SNAPSHOT版本验证
Sorry, something went wrong.
fix 1.x compatible api JSON#toJSON, for issue #2447
cf69590
https://github.com/alibaba/fastjson2/releases/tag/2.0.50 2.0.50已发布,请用新版本
No branches or pull requests
问题描述
环境信息
请填写以下信息:
重现步骤
以上代码使用 Fastjson 1.2.83可以通过测试用例
![image](https://private-user-images.githubusercontent.com/22017825/322511659-bfd8a404-818d-4732-ae29-87100d9047e8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MDE4MTIsIm5iZiI6MTczOTYwMTUxMiwicGF0aCI6Ii8yMjAxNzgyNS8zMjI1MTE2NTktYmZkOGE0MDQtODE4ZC00NzMyLWFlMjktODcxMDBkOTA0N2U4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDA2MzgzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk0YmQzYTFkMTViZWVmYzljYWY1ZmFhNDcyYmFiMGFlZWZiYzljZGUyOTk3YzlkZTFkYzY2ZDZkNzYyYzZlOTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.XqxDtA1a6qVNGMPYzymFsAX9b-OnGTR56Xs76tHoNGk)
使用Fastjson 2.0.49无法通过测试用例
经查是因为转换为JSONObject对象时,类型发生了变化
期待的正确结果
测试用例能够通过
![image](https://private-user-images.githubusercontent.com/22017825/322512740-4f628374-2e11-41b2-9023-124533826242.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MDE4MTIsIm5iZiI6MTczOTYwMTUxMiwicGF0aCI6Ii8yMjAxNzgyNS8zMjI1MTI3NDAtNGY2MjgzNzQtMmUxMS00MWIyLTkwMjMtMTI0NTMzODI2MjQyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDA2MzgzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU0MWUxMmYyN2VhNDVjMTQxN2E5ZjAyOWI4NWFjZmNkZGI0N2JjMTFmOTczMzExMWVjMWZjNjk3MmEyNzljZGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ZLJCquIbkMPeHXs7-pxGPUEwqyS_XlNoMtg3_vLR01M)
下图为Fastjson 1.2.83测试结果
The text was updated successfully, but these errors were encountered: