欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

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

程序员文章站 2022-06-30 13:55:23
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"}]}