在fastjson1中可以通过如下代码进行生成,但是在fastjson2进行了一些变动,具体代码如下:
fastjson1
import com.alibaba.fastjson.JSON;
// fastjson1
Foo foo = new Foo();
foo.setAnnouType("1");
String message = JSON.toJSONString(foo,
SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteNullListAsEmpty,
SerializerFeature.WriteNullStringAsEmpty);
fastjson2
import com.alibaba.fastjson2.JSON;
// fastjson2
Foo foo = new Foo();
foo.setAnnouType("1");
String aabb = JSON.toJSONString(wltxInterfaceParam,
JSONWriter.Feature.WriteNonStringValueAsString,
JSONWriter.Feature.NullAsDefaultValue
);