Android使用Gson解析json时候的泛类型丢失问题

原来的会丢失的错误代码:

  RootEntity<List<TagData>> entity;
                entity = new Gson().fromJson(result, RootEntity.class);

改正为:

    RootEntity<List<TagData>> entity;
                entity = new Gson().fromJson(result, new TypeToken<RootEntity<List<TagData>>>() {
                }.getType());
发布了46 篇原创文章 · 获赞 62 · 访问量 30万+

猜你喜欢

转载自blog.csdn.net/qq_27512671/article/details/51848473
今日推荐