wangxiaoer.put("major",new String[]{"烹饪","挖掘机"});得到的数据不完整,少了“]”

来源:3-1 JSON使用

flyingme

2016-12-15 11:56

JSONObject wangxiaoer = new JSONObject();

try {

Object objnull = null;

wangxiaoer.put("name","王小二");

wangxiaoer.put("age", 25.2);

wangxiaoer.put("birthday","1994-01-02");

wangxiaoer.put("school", "蓝翔");

wangxiaoer.put("major",new String[]{"烹饪","挖掘机"});

wangxiaoer.put("has_girlfriend",false);

wangxiaoer.put("car", objnull);

wangxiaoer.put("house", objnull);

wangxiaoer.put("comment", "这是一个注释");

Log.i("info", "===="+wangxiaoer.toString());

System.out.println("===="+wangxiaoer.toString());

} catch (JSONException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

得到的结果:{"birthday":"1994-01-02","school":"蓝翔","comment":"这是一个注释","has_girlfriend":false,"major":"[Ljava.lang.String;@4a7c04c0","age":25.2,"name":"王小二"}

求解:为甚么少了一个"]",major就不能构成数组对象


写回答 关注

3回答

JSON快速入门(Java版)

JSON和GSON的应用,JSON快速入门视频教程,赶快加入吧

102037 学习 · 163 问题

查看课程

相似问题