zoukankan      html  css  js  c++  java
  • GsonUtils.getGson().fromJson() 转泛型集合用法

    //计算其他收费
                List<QiTaFree> qiTaFreeList = GsonUtils.getGson().fromJson(exhiMain.getQiTaFressJson(), new TypeToken<List<QiTaFree>>(){}.getType());
                exhiMain.setQiTaFrees(qiTaFreeList);//其他
                if(qiTaFreeList !=null && qiTaFreeList.size()>0){
                    for(QiTaFree qiTaFree : qiTaFreeList){
                        if("1".equals(qiTaFree.getCalType())){//1表示以单位计算
                            otherCharges = (long) (otherCharges + qiTaFree.getPrice());
                        }else if("2".equals(qiTaFree.getCalType())){//表示以展位面积计算
                            otherCharges = otherCharges + Math.round(qiTaFree.getPrice() * zhanArea);
                        }
                        
                    }
                }//计算其他收费end

    当转集合泛型时候 请这样GsonUtils.getGson().fromJson(exhiMain.getQiTaFressJson(), new TypeToken<List<QiTaFree>>(){}.getType());

    如果比如这样转List<String> fanList = GsonUtils.getGson().fromJson(exhiMain.getFanWei(), ArrayList.class); 是不行的

  • 相关阅读:
    网络安全之常见攻击
    引入element-ui
    引入sass
    浏览器解析流程
    JDK8 HashMap--removeNode()移除节点方法
    JDK8 HashMap--treeify()树形化方法
    JDK1.8 HashMap--treeifyBin()方法
    二叉查找树ADT
    队列ADT

  • 原文地址:https://www.cnblogs.com/SHMILYHP/p/5766084.html
Copyright © 2011-2022 走看看