zoukankan      html  css  js  c++  java
  • gson.fromJson(json, new TypeToken<List<City>

     private List<City> loadCities() {
            // In this case we're loading from local assets.
            // NOTE: could alternatively easily load from network.
            // However, that would need to happen on a background thread.
            InputStream stream;
            try {
                stream = getAssets().open("cities.json");
            } catch (IOException e) {
                return null;
            }
    
            Gson gson = new GsonBuilder().create();
    
            JsonElement json = new JsonParser().parse(new InputStreamReader(stream));
    
            return gson.fromJson(json, new TypeToken<List<City>>() {
            }.getType());
        }
  • 相关阅读:
    Storm
    Linux 网络配置
    .NET Remoting
    jwt
    new操作符
    元数据
    C# lock
    三十而立
    面试
    灯火
  • 原文地址:https://www.cnblogs.com/endv/p/12230076.html
Copyright © 2011-2022 走看看