Java tutorial
/* * Copyright 2011-2016 MSUN.com All right reserved. This software is the confidential and proprietary information of * MSUN.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into with MSUN.com. */ package com.mmj.app.common.util; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; import com.google.gson.reflect.TypeToken; /** * @author zxc Nov 30, 2014 6:20:03 PM */ public class CityUtils { final static String CITY = // ? "[{\"id\":0,\"data\":[{\"id\":10101,\"name\":\"\"},{\"id\":10102,\"name\":\"\"},{\"id\":10103,\"name\":\"\"},{\"id\":10104,\"name\":\"?\"},{\"id\":10105,\"name\":\"\"},{\"id\":10106,\"name\":\"?\"},{\"id\":10107,\"name\":\"?\"},{\"id\":10108,\"name\":\"?\"},{\"id\":10109,\"name\":\"\"},{\"id\":10110,\"name\":\"\"},{\"id\":10111,\"name\":\"\"},{\"id\":10112,\"name\":\"\"},{\"id\":10113,\"name\":\"\"},{\"id\":10114,\"name\":\"?\"},{\"id\":10115,\"name\":\"?\"},{\"id\":10116,\"name\":\"\"},{\"id\":10117,\"name\":\"??\"},{\"id\":10118,\"name\":\"?\"},{\"id\":10119,\"name\":\"?\"},{\"id\":10120,\"name\":\"\"},{\"id\":10121,\"name\":\"\"},{\"id\":10122,\"name\":\"\"},{\"id\":10123,\"name\":\"?\"},{\"id\":10124,\"name\":\"\"},{\"id\":10125,\"name\":\"?\"},{\"id\":10126,\"name\":\"\"},{\"id\":10127,\"name\":\"?\"},{\"id\":10128,\"name\":\"\"},{\"id\":10129,\"name\":\"?\"},{\"id\":10130,\"name\":\"\"},{\"id\":10131,\"name\":\"?\"},{\"id\":10132,\"name\":\"\"},{\"id\":10133,\"name\":\"\"},{\"id\":10134,\"name\":\"?\"}]}" // + ",{\"id\":10101,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"?\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"?\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"\"},{\"id\":13,\"name\":\"\"},{\"id\":14,\"name\":\"\"},{\"id\":15,\"name\":\"\"},{\"id\":16,\"name\":\"\"},{\"id\":17,\"name\":\"\"}]}" // + ",{\"id\":10102,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"?\"},{\"id\":5,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"?\"},{\"id\":9,\"name\":\"?\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"?\"},{\"id\":13,\"name\":\"\"},{\"id\":14,\"name\":\"\"},{\"id\":15,\"name\":\"?\"},{\"id\":16,\"name\":\"?\"},{\"id\":17,\"name\":\"\"},{\"id\":18,\"name\":\"\"},{\"id\":19,\"name\":\"?\"},{\"id\":20,\"name\":\"?\"}]}" // + ",{\"id\":10103,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"??\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"?\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"?\"},{\"id\":9,\"name\":\"?\"},{\"id\":10,\"name\":\"?\"},{\"id\":14,\"name\":\"\"},{\"id\":15,\"name\":\"\"},{\"id\":16,\"name\":\"\"},{\"id\":17,\"name\":\"\"},{\"id\":18,\"name\":\"?\"},{\"id\":19,\"name\":\"\"},{\"id\":20,\"name\":\"\"},{\"id\":21,\"name\":\"\"}]}" // ? + ",{\"id\":10104,\"data\":[{\"id\":1,\"name\":\"?\"},{\"id\":2,\"name\":\"?\"},{\"id\":3,\"name\":\"??\"},{\"id\":4,\"name\":\"??\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"?\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"?\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"},{\"id\":13,\"name\":\"\"},{\"id\":14,\"name\":\"\"},{\"id\":15,\"name\":\"\"},{\"id\":16,\"name\":\"?\"},{\"id\":17,\"name\":\"\"},{\"id\":18,\"name\":\"\"},{\"id\":19,\"name\":\"\"},{\"id\":20,\"name\":\"\"},{\"id\":21,\"name\":\"?\"},{\"id\":22,\"name\":\"\"},{\"id\":23,\"name\":\"?\"},{\"id\":24,\"name\":\"\"},{\"id\":25,\"name\":\"\"},{\"id\":26,\"name\":\"\"},{\"id\":27,\"name\":\"?\"},{\"id\":28,\"name\":\"?\"},{\"id\":29,\"name\":\"\"},{\"id\":30,\"name\":\"\"},{\"id\":31,\"name\":\"\"},{\"id\":32,\"name\":\"\"},{\"id\":33,\"name\":\"\"},{\"id\":34,\"name\":\"\"},{\"id\":36,\"name\":\"\"},{\"id\":37,\"name\":\"?\"},{\"id\":38,\"name\":\"?\"},{\"id\":39,\"name\":\"\"},{\"id\":40,\"name\":\"???\"},{\"id\":41,\"name\":\"??\"},{\"id\":42,\"name\":\"?\"},{\"id\":43,\"name\":\"\"},{\"id\":44,\"name\":\"?\"}]}" // + ",{\"id\":10105,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"??\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"?\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"\"},{\"id\":13,\"name\":\"?\"}]}" // ? + ",{\"id\":10106,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"?\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"?\"},{\"id\":8,\"name\":\"?\"},{\"id\":9,\"name\":\"\"}]}" // ? + ",{\"id\":10107,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"?\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"??\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"?\"},{\"id\":12,\"name\":\"?\"},{\"id\":13,\"name\":\"\"},{\"id\":14,\"name\":\"\"}]}" // ? + ",{\"id\":10108,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"?\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"\"}]}" // + ",{\"id\":10109,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"?\"},{\"id\":3,\"name\":\"?\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"?\"},{\"id\":6,\"name\":\"?\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"?\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"}]}" // + ",{\"id\":10110,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"?\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"?\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"??\"}]}" // + ",{\"id\":10111,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"?\"},{\"id\":10,\"name\":\"?\"},{\"id\":11,\"name\":\"?\"}]}" // + ",{\"id\":10112,\"data\":[{\"id\":1,\"name\":\"?\"},{\"id\":2,\"name\":\"?\"},{\"id\":3,\"name\":\"?\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"?\"},{\"id\":6,\"name\":\"??\"},{\"id\":7,\"name\":\"?\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"??\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"?\"},{\"id\":13,\"name\":\"?\"},{\"id\":14,\"name\":\"\"},{\"id\":15,\"name\":\"\"},{\"id\":16,\"name\":\"\"},{\"id\":17,\"name\":\"?\"}]}" // + ",{\"id\":10113,\"data\":[{\"id\":1,\"name\":\"??\"},{\"id\":2,\"name\":\"?\"},{\"id\":3,\"name\":\"?\"},{\"id\":4,\"name\":\"?\"},{\"id\":5,\"name\":\"???\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"?\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"?\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"\"},{\"id\":13,\"name\":\"\"},{\"id\":14,\"name\":\"\"},{\"id\":15,\"name\":\"\"},{\"id\":16,\"name\":\"?\"}]}" // ? + ",{\"id\":10114,\"data\":[{\"id\":1,\"name\":\"?\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"?\"},{\"id\":4,\"name\":\"?\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"}]}" // ? + ",{\"id\":10115,\"data\":[{\"id\":1,\"name\":\"?\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"?\"},{\"id\":4,\"name\":\"?\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"\"}]}" // + ",{\"id\":10116,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"?\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"?\"},{\"id\":11,\"name\":\"?\"},{\"id\":12,\"name\":\"?\"},{\"id\":13,\"name\":\"\"},{\"id\":14,\"name\":\"\"}]}" // ?? + ",{\"id\":10117,\"data\":[{\"id\":1,\"name\":\"?\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"?\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"?\"}]}" // ? + ",{\"id\":10118,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"?\"},{\"id\":8,\"name\":\"?\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"?\"},{\"id\":13,\"name\":\"\"},{\"id\":14,\"name\":\"?\"},{\"id\":15,\"name\":\"\"},{\"id\":16,\"name\":\"\"},{\"id\":17,\"name\":\"\"},{\"id\":18,\"name\":\"?\"}]}" // ? + ",{\"id\":10119,\"data\":[{\"id\":1,\"name\":\"?\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"?\"},{\"id\":5,\"name\":\"?\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"?\"},{\"id\":8,\"name\":\"?\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"\"},{\"id\":13,\"name\":\"?\"}]}" // + ",{\"id\":10120,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"?\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"?\"},{\"id\":8,\"name\":\"?\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"?\"},{\"id\":11,\"name\":\"??\"},{\"id\":12,\"name\":\"\"},{\"id\":13,\"name\":\"?\"},{\"id\":14,\"name\":\"?\"},{\"id\":15,\"name\":\"\"},{\"id\":16,\"name\":\"\"},{\"id\":17,\"name\":\"\"}]}" // + ",{\"id\":10121,\"data\":[{\"id\":1,\"name\":\"?\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"?\"},{\"id\":5,\"name\":\"?\"},{\"id\":6,\"name\":\"?\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"?\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"}]}" // + ",{\"id\":10122,\"data\":[{\"id\":1,\"name\":\"?\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"?\"},{\"id\":5,\"name\":\"?\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"?\"},{\"id\":12,\"name\":\"\"},{\"id\":13,\"name\":\"\"},{\"id\":14,\"name\":\"\"},{\"id\":15,\"name\":\"\"},{\"id\":16,\"name\":\"\"},{\"id\":17,\"name\":\"\"}]}" // ? + ",{\"id\":10123,\"data\":[{\"id\":1,\"name\":\"?\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"?\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"?\"}]}" // + ",{\"id\":10124,\"data\":[{\"id\":1,\"name\":\"?\"},{\"id\":2,\"name\":\"?\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"?\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"??\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"}]}" // ? + ",{\"id\":10125,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"\"},{\"id\":14,\"name\":\"\"},{\"id\":15,\"name\":\"\"}]}" // + ",{\"id\":10126,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"?\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"?\"},{\"id\":5,\"name\":\"?\"},{\"id\":6,\"name\":\"?\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"?\"}]}" // ? + ",{\"id\":10127,\"data\":[{\"id\":1,\"name\":\"?\"},{\"id\":2,\"name\":\"?\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"?\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"??\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"\"},{\"id\":13,\"name\":\"\"},{\"id\":14,\"name\":\"?\"},{\"id\":15,\"name\":\"\"},{\"id\":16,\"name\":\"\"},{\"id\":17,\"name\":\"\"},{\"id\":18,\"name\":\"\"},{\"id\":19,\"name\":\"??\"},{\"id\":20,\"name\":\"\"},{\"id\":21,\"name\":\"\"}]}" // + ",{\"id\":10128,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"?\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"?\"},{\"id\":13,\"name\":\"\"},{\"id\":14,\"name\":\"\"},{\"id\":15,\"name\":\"\"},{\"id\":16,\"name\":\"\"},{\"id\":17,\"name\":\"\"},{\"id\":18,\"name\":\"\"},{\"id\":19,\"name\":\"?\"},{\"id\":20,\"name\":\"??\"},{\"id\":21,\"name\":\"\"}]}" // ? + ",{\"id\":10129,\"data\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"?\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"?\"},{\"id\":5,\"name\":\"?\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"\"},{\"id\":13,\"name\":\"\"},{\"id\":14,\"name\":\"\"},{\"id\":15,\"name\":\"?\"},{\"id\":16,\"name\":\"?\"}]}" // + ",{\"id\":10130,\"data\":[{\"id\":1,\"name\":\"??\"},{\"id\":2,\"name\":\"\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"?\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"\"},{\"id\":12,\"name\":\"\"},{\"id\":13,\"name\":\"\"},{\"id\":14,\"name\":\"\"}]}" // ? + ",{\"id\":10131,\"data\":[{\"id\":0,\"name\":\"?\"},{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"?\"},{\"id\":3,\"name\":\"\"},{\"id\":4,\"name\":\"\"},{\"id\":5,\"name\":\"\"},{\"id\":6,\"name\":\"\"},{\"id\":7,\"name\":\"\"},{\"id\":8,\"name\":\"?\"},{\"id\":9,\"name\":\"\"},{\"id\":10,\"name\":\"\"},{\"id\":11,\"name\":\"?\"},{\"id\":12,\"name\":\"?\"},{\"id\":13,\"name\":\"?\"},{\"id\":14,\"name\":\"\"},{\"id\":15,\"name\":\"\"},{\"id\":16,\"name\":\"?\"},{\"id\":17,\"name\":\"\"},{\"id\":18,\"name\":\"\"},{\"id\":19,\"name\":\"\"}]}" // + ",{\"id\":10132,\"data\":[{\"id\":1,\"name\":\"\"}]}" // + ",{\"id\":10133,\"data\":[{\"id\":1,\"name\":\"\"}]}" // ? + ",{\"id\":10134,\"data\":[{\"id\":1,\"name\":\"?\"},{\"id\":2,\"name\":\"\"},{\"id\":4,\"name\":\"?\"}]}" // + "]"; final static Map<Integer, List<CityMeta>> map = parse(CITY); public static List<CityMeta> getCityById(Integer id) { return map.get(id); } private static Map<Integer, List<CityMeta>> parse(String json) { final Gson gson = new GsonBuilder().registerTypeAdapter(Double.class, new JsonSerializer<Double>() { @Override public JsonElement serialize(Double src, Type typeOfSrc, JsonSerializationContext context) { Integer value = src.intValue(); return new JsonPrimitive(value); } }).create(); List<?> list = gson.fromJson(json, new TypeToken<Object>() { }.getType()); if (list == null || list.size() == 0) { return Collections.emptyMap(); } Map<Integer, List<CityMeta>> map = new HashMap<Integer, List<CityMeta>>(); for (Object obj : list) { if (obj == null) { continue; } if (obj instanceof Map<?, ?>) { Number parentId = (Number) ((Map<?, ?>) obj).get("id"); Integer pId = parentId.intValue(); List<?> data = (List<?>) ((Map<?, ?>) obj).get("data"); if (parentId == null || data == null) { continue; } List<CityMeta> cityList = new ArrayList<CityUtils.CityMeta>(); for (Object value : data) { if (value instanceof Map<?, ?>) { cityList.add(new CityMeta((Double) ((Map<?, ?>) value).get("id"), (String) ((Map<?, ?>) value).get("name"))); } } map.put(pId, cityList); } } return map; } public static class CityMeta { private Integer id; private String name; public CityMeta(Double id, String name) { this.id = (int) Math.round(id); this.name = name; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } }