Caused by: java.lang.NumberFormatException: Invalid double: “” with blank value

后端 未结 2 962
囚心锁ツ
囚心锁ツ 2021-01-28 02:59

I get ther error when JSON string have some blank value, getting from server, how to deal with blank values here is JSON

{  
   \"status\":\"succes         


        
相关标签:
2条回答
  • 2021-01-28 03:24
    public int image_width;     // Expected integer value while parsing 
    
    public int image_height;   // Expected integer value while parsing
    

    as you can see below you are having string fields . Initialize below vale to 0

    "image_width":0,
    "image_height":0
    
    0 讨论(0)
  • 2021-01-28 03:35

    Change the type of image_width and image_height to String in MyData Class

    public String image_width;
    
    public String image_height;
    

    As int will not be able to store "" this string, and at the time of using it you can parse it into int.

    0 讨论(0)
提交回复
热议问题