zoukankan      html  css  js  c++  java
  • Android udp json+数组 --->bytes发送数据

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

        

      

  • 相关阅读:
    CF703D Mishka and Interesting sum
    CF697D Puzzles
    SCOI2017酱油记
    [BZOJ4730][清华集训2016][UOJ266] Alice和Bob又在玩游戏
    BZOJ4311:向量
    BZOJ4520: [Cqoi2016]K远点对
    BZOJ4555: [Tjoi2016&Heoi2016]求和
    [Codechef November Challenge 2012] Arithmetic Progressions
    agc040
    补题
  • 原文地址:https://www.cnblogs.com/wbdream/p/9851266.html
Copyright © 2011-2022 走看看