import net.sf.json.JSONObject;
public class TestJSONObject {
public static void main(String[] args) {
JSONObject jo = JSONObject.fromObject("{\"int\":1,\"bool\":true}");
System.out.println(jo.getBoolean("bool"));
System.out.println(jo.getInt("int"));
}
}
会在字符串中得到数据,并给其赋值。
结果为:
true
1