public static void createJSONByBean(){
Shuaige xjz=new Shuaige();
try {
xjz.setName("谢吉喆");
xjz.setSex("男");
xjz.setAge(21);
xjz.setBirthday("1996-04-04");
xjz.setlikeAnimals(new String[]{"cat","dog"});
xjz.setGirlFriend(true);
xjz.setCar(null);
xjz.setHouse(null);
System.out.println(new JSONObject().fromObject(xjz));
} catch (JSONException e) {
e.printStackTrace();
控制台输出 JSON格式的结果
frece
相关分类