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? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
简要描述您碰到的问题。 前提:fastjson2 的默认字符串输出特性是 字符串如果是 null 则不会输出该字段 问题:
null
JSONWriter.Feature.WriteNullListAsEmpty
[]
字符串为 null 时不输出该字段
JSONWriter.Feature.BrowserCompatible
请填写以下信息:
如何操作可以重现该问题:
package com.example.demo; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONWriter; import java.io.Serializable; public class DemoApplication { public static void main(String[] args) { Response response = new Response(); response.setSuccess(true); // {"success":true} 默认没有问题 System.out.println(JSON.toJSONString(response)); // {"errCode":null,"errMessage":null,"success":true} 这里有问题 System.out.println(JSON.toJSONString(response, JSONWriter.Feature.WriteNullListAsEmpty)); // {"success":true} 这个也没问题 System.out.println(JSON.toJSONString(response, JSONWriter.Feature.BrowserCompatible)); } public static class Response implements Serializable { private static final long serialVersionUID = 1L; /** * successful */ private boolean success; /** * error code */ private String errCode; /** * error message */ private String errMessage; public boolean isSuccess() { return success; } public void setSuccess(boolean success) { this.success = success; } public String getErrCode() { return errCode; } public void setErrCode(String errCode) { this.errCode = errCode; } public String getErrMessage() { return errMessage; } public void setErrMessage(String errMessage) { this.errMessage = errMessage; } } }
对您期望发生的结果进行清晰简洁的描述。 设置 JSONWriter.Feature.WriteNullListAsEmpty 不影响缺省的字符串输出行为
请复制并粘贴任何相关的日志输出。
如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。
The text was updated successfully, but these errors were encountered:
fix WriteNullListAsEmpty, for issue #878
d120ce9
https://github.com/alibaba/fastjson2/releases/tag/2.0.17 问题已修复,请用新版本
Sorry, something went wrong.
No branches or pull requests
问题描述
简要描述您碰到的问题。
前提:fastjson2 的默认字符串输出特性是 字符串如果是
null
则不会输出该字段问题:
JSONWriter.Feature.WriteNullListAsEmpty
特性时,貌似会覆盖缺省的字符串输出行为,可是明明设置的特性是空数组输出为[]
,为什么把字符串为 null 时不输出该字段
这个默认的特性给整没了 ?JSONWriter.Feature.BrowserCompatible
特性时,表现又是正确的环境信息
请填写以下信息:
重现步骤
如何操作可以重现该问题:
期待的正确结果
对您期望发生的结果进行清晰简洁的描述。
设置
JSONWriter.Feature.WriteNullListAsEmpty
不影响缺省的字符串输出行为相关日志输出
请复制并粘贴任何相关的日志输出。
附加信息
如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。
The text was updated successfully, but these errors were encountered: