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] 序列化 toJSONBytes 时,如果属性为 null,序列化后的 bytes 转 String 时,格式不对,多了 “,” #1603

Closed
DemonJun opened this issue Jun 27, 2023 · 1 comment
Labels
bug Something isn't working fixed
Milestone

Comments

@DemonJun
Copy link

问题描述

简要描述您碰到的问题。

序列化 toJSONBytes 时,如果属性为 null,序列化后的 bytes 转 String 时,格式不对,多了 “,”

环境信息

请填写以下信息:

  • OS信息: Macos 13
  • JDK信息: openjdk 11
  • 版本信息:fastjson2 2.0.33/2.0.34

重现步骤

如何操作可以重现该问题:

    JSONObject jsonObject =
        JSON.parseObject(
            "{\"deviceId\":\"16584\",\"srcAddress\":\"109.55.156.215\",\"ssssss\":null}");
    byte[] jsonBytes = JSON.toJSONBytes(jsonObject);
    System.out.println(new String(jsonBytes));

期待的正确结果

{"deviceId":"16584","srcAddress":"109.55.156.215"}

相关日志输出

{"deviceId":"16584","srcAddress":"109.55.156.215",}

附加信息

image
@DemonJun DemonJun added the bug Something isn't working label Jun 27, 2023
@wenshao wenshao added this to the 2.0.35 milestone Jul 1, 2023
@wenshao wenshao added the fixed label Jul 8, 2023
@wenshao
Copy link
Member

wenshao commented Jul 9, 2023

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

@wenshao wenshao closed this as completed Jul 9, 2023
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

2 participants