{ "Sherlock":{
"age":"42",
"id":"1"
},
"John":[{
"gender":"male",
"hair":"brown"
}]
}
第一个键值对这样操作: JSONObject object = new JSONObject(); Map<String, String> map = new HashMap<String, String>(); map.put("age", "42"); map.put("id", "1"); object.put("Sherlock",map);
但是第二个键值对的 value 是个数组怎么弄啊,自学中。。谢谢
1
kary1 2017-08-09 22:00:47 +08:00 via Android
map<string,object>不就 ok 了?
|
3
simon7 2017-08-10 09:19:11 +08:00 via iPhone
JSONArray
|
4
thinkmore 2017-08-10 10:27:47 +08:00
List<User> list = new ArrayList<>();
User user = new User(); user.setGender("male");user.setHair("brown"); list.add(user); map.put("John",list); |