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]关于jsonDirect=true报错 #2347

Closed
yoyo-520 opened this issue Mar 20, 2024 · 2 comments
Closed

[BUG]关于jsonDirect=true报错 #2347

yoyo-520 opened this issue Mar 20, 2024 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@yoyo-520
Copy link

yoyo-520 commented Mar 20, 2024

问题描述

当某个字段设置了jsonDirect=true,能否为null的时候调用JSON.toJsonString不报错

@getter
@Setter
public class TestJson2 {

private String name;

@JSONField(jsonDirect = true)
private String jsonStr;

}

public static void main(String[] args) {
TestJson2 testJson2 = new TestJson2();
testJson2.setName("测试");
System.out.println(JSON.toJSONString(testJson2));
}

当jsonStr为null的时候报错:
image

期望输出结果为:{"jsonStr":null,"name":"测试"}

@yoyo-520 yoyo-520 added the bug Something isn't working label Mar 20, 2024
@wenshao wenshao added this to the 2.0.48 milestone Mar 20, 2024
@wenshao wenshao added the fixed label Mar 20, 2024
@wenshao
Copy link
Member

wenshao commented Mar 20, 2024

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

@wenshao
Copy link
Member

wenshao commented Mar 25, 2024

@wenshao wenshao closed this as completed Mar 25, 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

2 participants