码迷,mamicode.com
首页 > 移动开发 > 详细

Android udp json+数组 --->bytes发送数据

时间:2018-10-25 18:02:25      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:code   array   cmd   gets   bsp   class   pad   ken   sonar   

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"}]}

 

    

  

Android udp json+数组 --->bytes发送数据

标签:code   array   cmd   gets   bsp   class   pad   ken   sonar   

原文地址:https://www.cnblogs.com/wbdream/p/9851266.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!