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
询问有关本项目的使用和其他方面的相关问题。 JSON字符串如下:
{ "salaryStart": { "$numberDecimal": "6000" }, "salaryEnd": { "$numberDecimal": "9000" } }
由于MongoDB不支持BigDecimal类型, 需转换成Decimal128存储。
@ReadingConverter @WritingConverter public class BigDecimalToDecimal128Converter implements Converter<Decimal128, BigDecimal> { @Override public BigDecimal convert(Decimal128 decimal128) { return decimal128.bigDecimalValue(); } }
public class PositionDO{ //综合薪资范围起 private BigDecimal salaryStart; //综合薪资范围止 private BigDecimal salaryEnd; }
所以支持mongodb类型和java类型互转。
现在用原对象接收,抛异常 Exception in thread "Thread-8" com.alibaba.fastjson2.JSONException: TODO : 6
__问:如何用BigDecimal 接收这样的类型字段,怎样将converter使用进去?_
The text was updated successfully, but these errors were encountered:
异常是com.alibaba.fastjson2.JSONReader#getBigDecimal 方法抛出来的,因为识别不了此类型,抛异常了
Sorry, something went wrong.
Decimal128 这个类是org.bson.types.Decimal128 么?
已经内置支持,请用2.0.7-SNAPSHOT版本验证下 https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.7-SNAPSHOT/
是的
好的 谢谢 我验证下
https://github.com/alibaba/fastjson2/releases/tag/2.0.7 问题已经修复,请用新版本
No branches or pull requests
请描述您的问题
询问有关本项目的使用和其他方面的相关问题。
JSON字符串如下:
由于MongoDB不支持BigDecimal类型, 需转换成Decimal128存储。
spring 定义转换器
对象字段
所以支持mongodb类型和java类型互转。
现在用原对象接收,抛异常 Exception in thread "Thread-8" com.alibaba.fastjson2.JSONException: TODO : 6
__问:如何用BigDecimal 接收这样的类型字段,怎样将converter使用进去?_
The text was updated successfully, but these errors were encountered: