Android json支持五種數據類型 String / int(float)/bool / null / object 今天說 object : ...
Android json支持五種數據類型
String / int(float)/bool / null / object
今天說 object :
json = new JSONObject(); json.put("cmd","put"); json.put("token",tokenJson.getString("token")); json.put("ID",jsonObject.getString("ID")); json.put("type",jsonObject.getString("type")); json.put("pwd",jsonObject.getString("pwd")); json.put("ul",jsonObject.getString("ul")); json.put("zt",jsonObject.getString("zt")); json.put("lt",jsonObject.getString("lt"));
JSONArray array=new JSONArray(jsonObject.getString("ll"));
json.put("ll", array);
結果:
{"cmd":"put","token":"bcfcf2440ef3f6445647578c54c11a0c","ID":"ZG000112","type":"4","pwd":"console","ul":"1","zt":"1","lt":"1","bool":true,"ll":[{"IpPort":3000,"Lable":"land1","Enable":1,"IpAddr":"192.168.4.22"},{"IpPort":3000,"Lable":"land2","Enable":0,"IpAddr":"192.168.4.23"},{"IpPort":3000,"Lable":"land3","Enable":0,"IpAddr":"192.168.4.24"},{"IpPort":3000,"Lable":"land4","Enable":0,"IpAddr":"192.168.4.25"}]}