美文网首页
JSON 和 Bean对象,List集合的转换

JSON 和 Bean对象,List集合的转换

作者: zhengLH | 来源:发表于2019-03-14 14:54 被阅读0次

【1】json 转换成Bean對象:

ProductBean productBean = new Gson().fromJson(oneProductResponse.toString(), ProductBean.class);

【2】json 转换成List集合:

  List<ProductBean>  mProductBeanList = (List<ProductBean>)
   new  Gson().fromJson(productResponse.toString(),
                            new TypeToken<List<ProductBean>>() {
                            }.getType());

相关文章

网友评论

      本文标题:JSON 和 Bean对象,List集合的转换

      本文链接:https://www.haomeiwen.com/subject/ufgqmqtx.html