qq_慕码人5248226
2019-08-27 18:03
Object nullObj = null;
private static void JSONObject() {
// TODO Auto-generated method stub
JSONObject wangxiaoer = new JSONObject();
wangxiaoer.put("name", "王小二");
wangxiaoer.put("age", 25.2);
wangxiaoer.put("birthday", "1990-01-01");
wangxiaoer.put("major" ,new String[]{"炒菜","挖掘机"});
wangxiaoer.put("car",nullObj);
wangxiaoer.put("house",nullObj);
System.out.println(wangxiaoer.toString());
}
}
得出来的结果是这样的
{"car":null,"birthday":"1990-01-01","age":25.2,"name":"王小二","house":null,"major":[Ljava.lang.String;@b166b5}
private static void JSONObject() {
Object nullObj = null;
JSONObject wangxiaoer = new JSONObject();
wangxiaoer.put("name", "王小二");
wangxiaoer.put("age", 25.2);
wangxiaoer.put("birthday", "1990-01-01");
wangxiaoer.put("major" ,new String[]{"炒菜","挖掘机"});
wangxiaoer.put("car",nullObj);
wangxiaoer.put("house",nullObj);
System.out.println(wangxiaoer.toString());
}
}
酱紫
JSON快速入门(Java版)
102037 学习 · 163 问题
相似问题