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

@JSONField name 不支持 private 字段 #2866

Closed
wangjing112 opened this issue Nov 8, 2019 · 2 comments
Closed

@JSONField name 不支持 private 字段 #2866

wangjing112 opened this issue Nov 8, 2019 · 2 comments

Comments

@wangjing112
Copy link

测试代码:
` @test
public void testPrivate() {
String json = "{"A1":1,"A2":2,"A3":3}";

	A a = JSON.parseObject(json, A.class, Feature.SupportNonPublicField);

	System.out.println(String.format("a1:%d,a2:%d,a3:%d",a.a1,a.A2,a.a3));
}

static class A{
	@JSONField(name="A1")
	int a1;
	int A2;
	@JSONField(name="A3")
	public int a3;
}

`

输出:
a1:0,a2:2,a3:3

@biyanwen
Copy link
Contributor

biyanwen commented Nov 9, 2019

属性私有就必须有setter方法,否则无法反序列化。

@Licker05
Copy link

属性私有就必须有setter方法,否则无法反序列化。

那A2咋就可以反序列化成功,不是这个问题吧,我觉得就是个BUG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants