50,503
社区成员
发帖
与我相关
我的任务
分享
WARN JSONObject:202 - Property 'charAt' has no read method. SKIPPED
WARN JSONObject:202 - Property 'length' has no read method. SKIPPED
JSONObject paramJson = JSONObject.fromObject(param);
import net.sf.json.JSONObject;
public class Study02 {
private int charAt;
private int length;
public int getCharAt() { return charAt; }
public void setCharAt(int charAt) { this.charAt = charAt; }
public int getLength() { return length; }
public void setLength(int length) { this.length = length; }
public static void main(String[] args) {
String json = "{\"charAt\":1,\"length\":10}";
JSONObject obj = JSONObject.fromObject(json);
System.out.println(obj.toString());
Study02 sd = (Study02) JSONObject.toBean(obj,Study02.class);
System.out.println(sd.charAt);
}
}