解析json字符串

引入maven依赖:
        
            org.json
            json
            20160810
        
        String jsonStr = "{\"浙江\":19,\"上海\":18,\"江苏\":5,\"福建\":6}";
        JSONObject jsonObject = new JSONObject(jsonStr);
        Iterator iterator = jsonObject.keys();
        while (iterator.hasNext()) {
            String key = iterator.next().toString();
            System.out.println(key + "---->" + jsonObject.get(key));
        }

你可能感兴趣的:(解析json字符串)