String转List>

String appNames = "[{\"cpuNumber\":4,\"memorySize\":8,\"serverName\":\"ddd\",\"serversNumber\":1},{\"cpuNumber\":4,\"memorySize\":8,\"serverName\":\"aaa\",\"serversNumber\":1},{\"cpuNumber\":2,\"memorySize\":4,\"serverName\":\"bbb\",\"serversNumber\":1}]";
List> list = (List>) JSONArray.parse(appNames);
        System.out.println(list);
        for(Map mapList : list){
            System.out.println(mapList);
            for(Map.Entry entry : mapList.entrySet()){
                System.out.println(entry.getKey());
                System.out.println(entry.getValue());
                if("serverName".equals(entry.getKey())){
                    System.out.println(entry.getValue());
                }
            }
        }

你可能感兴趣的:(String转List>)