- summary: to --> toBean does not recognize write method when write method's
toBean does not recognize write method when write method's return value is not void.
for example, the following testcase[1], there are two class B and A, B's setter does not return void, and toBean does not work for it.
please support this, thanks.
the output of the testcase:
May 27, 2009 4:53:34 PM net.sf.json.JSONObject toBean
WARNING: Property 'a' of class com.kingsoft.bgd.service.GaeServiceImplTest$B has no write method. SKIPPED.
0
1
[1]
public class JsonTest {
@Test
public void testJson() {
JSONObject jsonObject = JSONObject.fromObject("{a:1}");
B b = (B) jsonObject.toBean(jsonObject, B.class);
System.out.println(b.getA());
A a = (A) jsonObject.toBean(jsonObject, A.class);
System.out.println(a.getA());
}
public static class B {
private int a;
public B setA(int a) {
this.a = a;
return this;
}
public int getA() {
return a;
}
}
public static class A {
private int a;
public void setA(int a) {
this.a = a;
}
public int getA() {
return a;
}
}