需要格式如下

    1. [
    2. {
    3. key:"aaa",
    4. name:"bbbb"
    5. },
    6. {
    7. key:"aaa1",
    8. name:"bbb2"
    9. },
    10. ....
    11. ]

    但是接口返回格式如下

    1. {"code":0,
    2. "data":"{\"xxx1\":\"日期1\",\"xxx2\":\"时段1\",\"xxx3\":\"x角色2\",
    3. \"xxx4\":\"新增角色\",\"xxx5\":\"充值RMB\",\"xxx6\":\"充值次数\",\"xxx7\":\"充值角色\",
    4. \"xxx8\":\"新增付费角色数\",\"xxx9\":\"角色留存数\",\"xxx10\":\"活跃ARPU\"}",
    5. "encrypt":false,
    6. "msg":"ok",
    7. "success":true
    8. }

    接下来看java 如何转化

    1. List<Map<String, Object>> resultData = new ArrayList<>();
    2. HttpClient httpClient = new HttpClient();
    3. GetMethod getMethod = new GetMethod(url);
    4. int status = httpClient.executeMethod(getMethod);
    5. if(status == 200){
    6. String body = getMethod.getResponseBodyAsString();
    7. JSONObject jsonObject = JsonUtil.JSONStrToJSONObject(body) ;
    8. JSONObject tmpData = jsonObject.getJSONObject("data") ; //拿到data数据
    9. if(tmpData!=null && tmpData.size()>0 ){
    10. for (String key : tmpData.keySet()) {
    11. HashMap<String, Object> tmpMap = new HashMap<String, Object>() {
    12. {
    13. put("key", key);
    14. put("name", tmpData.get(key));
    15. }
    16. };
    17. resultData.add(tmpMap) ;
    18. }
    19. }
    20. system.out.printIn(resultData);//这就是你想要的数据了
    21. return "xxxxx";
    22. }else{
    23. return "xxxxx";
    24. }