fastjson SerializerFeature in @JSONField should be prior to JSON.toJSONString, for WriteMapNullValue and WriteNullStringAsEmpty

lmyy7pcs  于 2021-11-27  发布在  Java
关注(0)|答案(0)|浏览(275)

When SerializerFeature.WriteNullStringAsEmpty given in JSON.toJSONString, SerializerFeature.WriteMapNullValue in @JSONField does not work.

public class TestJson {
	@JSONField(serialzeFeatures=SerializerFeature.WriteMapNullValue)
	public String getValue() {
		return null;
	}

	public static void main(String[] args) throws Exception {
		System.out.println(JSON.toJSONString(new TestJson(), SerializerFeature.WriteNullStringAsEmpty));
	}
}

Expects {"value":null} but actually gets {"value":""}.

Version: 1.2.63_preview_01

Jackson alaways use @JsonInclude or @JsonSerialize on fields/methods prior to ObjectMapper settings.

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题