在json中new String[]出現(xiàn)了亂碼
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());
}
}
得出來的結(jié)果是這樣的
{"car":null,"birthday":"1990-01-01","age":25.2,"name":"王小二","house":null,"major":[Ljava.lang.String;@b166b5}
2019-09-11
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());
}
}
醬紫