码迷,mamicode.com
首页 > 其他好文 > 详细

GsonFormat 报错

时间:2016-08-02 23:57:04      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:

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": "灏辩畻鐢熸椿鍐嶈嫤閫硷紝鎴戜滑浠嶉渶灏忓揩涔愶紒绗戦湼鏉ヤ簡锛岀粰浣犱笉涓€鏍风殑蹇箰銆傜嫭涔愪箰锛屼笉濡備紬涔愪箰銆?"
        },

 

GsonFormat 报错

标签:

原文地址:http://www.cnblogs.com/johnsonwei/p/5731127.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!