zoukankan      html  css  js  c++  java
  • json数组解析

     1 private String collectDataJson(String dataListJson){
     2 
     3         String topic = HBPHelper.getTopic(HBPCollectorConstant.PIPELINE_INFO, 1);
     4 
     5         JSONObject resObj = JSON.parseObject(dataListJson);
     6         if (false==resObj.containsKey("data")) {
     7             return "参数不符合规范";
     8         }
     9         Object data = resObj.get("data");
    10         if (data instanceof JSONArray) {
    11             JSONArray jsonArray = (JSONArray) data;
    12             LOG.info("start to collect data,data num is [{}]", jsonArray.size());
    13             for (int i=0;i<jsonArray.size();i++) {
    14                 String jsonString = jsonArray.getString(i);
    15                 if (jsonString.length() < PB_LENGTH) {
    16                     return "pb数据长度应大于" + PB_LENGTH;
    17                 }
    18                 byte[] jsonByte = HBPHelper.decode(jsonString);
    19                 KafkaUtil.getINSTANCE().getByteProducer(topic).send(jsonByte);
    20             }
    21         }
    22         return "OK";
    23     }
  • 相关阅读:
    3.15第三周编程总结
    2019.3.9编程总结
    2019.3.3编程总结2
    编程总结1
    编程总结2
    编程总结3
    我的老师
    关于sublime text 3使用记录
    12. 整数转罗马数字
    4. 寻找两个有序数组的中位数
  • 原文地址:https://www.cnblogs.com/jinniezheng/p/6397466.html
Copyright © 2011-2022 走看看