Giter Club home page Giter Club logo

Comments (8)

yanxutao89 avatar yanxutao89 commented on June 2, 2024

image
上图符合你的目的吗?

from fastjson2.

moyu1106 avatar moyu1106 commented on June 2, 2024

很感谢您的帮助,对不起,我没能很好地讲清楚我的需求!
我的业务中关于金额(假设字段为Integer),0和null都是有意义的,没有设置Integer的值那么它将为null,设置了0就是0,当从数据库查询一条数据是如果integer没有值则为null(也是期望的序列化的默认值);

//例子A:
Bean beanA =new Bean();
beanA.setInteage(0);
//sout:
{"integer":0}

//例子B:
Bean beanA =new Bean();
beanA.setInteage(null);
//sout:
{"integer":null}

用一句话来总结就是我只想某个类的序列化效果是注释掉fastJsonConfig中的JSONWriter.Feature.WriteNullNumberAsZero的样子,而现在的情况是全局配置的优先级貌似高于我自己的实现了!

from fastjson2.

yanxutao89 avatar yanxutao89 commented on June 2, 2024

image
这样貌似可以?

from fastjson2.

moyu1106 avatar moyu1106 commented on June 2, 2024

调用toJsonString的话是可以的,但是我在调用接口时会得到不一致的结果
Uploading 91a82eef63f22af0b3729c5e6380c8b.png…

from fastjson2.

yanxutao89 avatar yanxutao89 commented on June 2, 2024

可以提供简单的复现用例吗?

from fastjson2.

moyu1106 avatar moyu1106 commented on June 2, 2024

fastjson2-test.zip
我上传了一个压缩包,一个springboot项目,您可以通过TestController中的接口测试,非常感谢大佬的帮助!

from fastjson2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.