GsonFormat 报错

GsonFormat原来也有bug

我是用GsonFormat来生成java bean的,但是运行起来居然报

Caused by: java.lang.NumberFormatException: Expected an int but was 4.5 at line 58 column 25 path $.list[4].stars

原来,它生成javabean是一个int型,但是获取到的居然有int,也有float

javabean如下

 1     public static class ListBean {
 2 
 3         private int id;
 4         private String name;
 5         private String packageName;
 6         private String iconUrl;
 7         private float stars;
 8         private int size;
 9         private String downloadUrl;
10         private String des;

我改成float了。

 

数据中star有整型也有float型的:

        {
            "id": 1631363,
            "name": "鐢锋€х浜哄尰鐢�",
            "packageName": "com.medapp.man",
            "iconUrl": "app/com.medapp.man/icon.jpg",
            "stars": 4,
            "size": 1979701,
            "downloadUrl": "app/com.medapp.man/com.medapp.man.apk",
            "des": "鐢锋€х浜哄尰鐢熸槸涓€娆句笓闂ㄩ拡瀵圭敺鎬х敓鐞嗗仴搴蜂互鍙婂叾浠栫浉鍏充笓绉戠梾鐥囨彁渚涘厤璐瑰湪绾垮挩璇㈢殑鍖荤枟"
        },
        {
            "id": 1637000,
            "name": "绗戦湼鏉ヤ簡(涓栫晫鏉増)",
            "packageName": "com.zuobao.xiaobao",
            "iconUrl": "app/com.zuobao.xiaobao/icon.jpg",
            "stars": 4.5,
            "size": 4365674,
            "downloadUrl": "app/com.zuobao.xiaobao/com.zuobao.xiaobao.apk",
            "des": "灏辩畻鐢熸椿鍐嶈嫤閫硷紝鎴戜滑浠嶉渶灏忓揩涔愶紒绗戦湼鏉ヤ簡锛岀粰浣犱笉涓€鏍风殑蹇箰銆傜嫭涔愪箰锛屼笉濡備紬涔愪箰銆�"
        },

 

posted @ 2016-08-02 23:09  达哥的博客  阅读(522)  评论(0编辑  收藏  举报