Skip to content
New issue

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

[BUG] 版本2.0.46 引用类型、Boolean、Short 不支持JSONWriter.Feature.WriteNulls #2234

Closed
focuse8 opened this issue Feb 4, 2024 · 6 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@focuse8
Copy link

focuse8 commented Feb 4, 2024

问题描述

简要描述您碰到的问题。
序列化指定了JSONWriter.Feature.WriteNulls,对于Boolean、Short类型null没有正常序列号

fastjson2版本:2.0.46

附加信息

*如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。
com.alibaba.fastjson2.writer.ObjectWriterCreatorASM#gwFieldValueJSONB
不同于Integer Long String Date,其它引用生成的字节码是com.alibaba.fastjson2.writer.ObjectWriterCreatorASM#gwFieldValueObjectJSONB。这里没有对JSONWriter.Feature.WriteNulls特性进行支持

@focuse8 focuse8 added the bug Something isn't working label Feb 4, 2024
@rowstop
Copy link
Contributor

rowstop commented Feb 4, 2024

没有复现,你能给个可复现 demo 吗
image

@focuse8
Copy link
Author

focuse8 commented Feb 4, 2024

没有复现,你能给个可复现 demo 吗 image

你给bool设一个默认值 numberShort一个默认值
public static void main(String[] args) {
Obj obj = new Obj();
obj.aShort = null;
obj.bool = null;

    byte[] bytes = JSONB.toBytes(
            obj,
            JSONWriter.Feature.WriteNulls);


    Obj result = JSONB.parseObject(
            bytes,
            Obj.class);
}

class Obj {
Boolean bool = true;

Short aShort = 12;

}

@rowstop
Copy link
Contributor

rowstop commented Feb 5, 2024

没复现
image

@focuse8
Copy link
Author

focuse8 commented Feb 5, 2024

JSONWriter.Feature.WriteNulls,
JSONWriter.Feature.FieldBased

4f7da721-16ae-40b0-ade9-6472b4920cc0

@wenshao wenshao added this to the 2.0.47 milestone Feb 8, 2024
wenshao added a commit that referenced this issue Feb 9, 2024
@wenshao
Copy link
Member

wenshao commented Feb 9, 2024

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.47-SNAPSHOT/
问题已修复,请帮忙用2.0.47-SNAPSHOT版本验证,2.0.47版本预计在2月底发布

@wenshao wenshao added the fixed label Feb 9, 2024
@wenshao
Copy link
Member

wenshao commented Feb 24, 2024

https://github.com/alibaba/fastjson2/releases/tag/2.0.47
问题已修复,请用新版本

@wenshao wenshao closed this as completed Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

3 participants