Can not deserialize instance of java.lang.String out of START_ARRAY token

前端 未结 1 1860
栀梦
栀梦 2021-02-02 09:14

I am very new to the Jackson parser. My code was running fine until today. I am not able to figure out the error.

Exception in thread \"main\" com.fasterxml.jack         


        
1条回答
  •  一向
    一向 (楼主)
    2021-02-02 09:28

    The error is:

    Can not deserialize instance of java.lang.String out of START_ARRAY token at [Source: line: 1, column: 1095] (through reference chain: JsonGen["platforms"])

    In JSON, platforms look like this:

    "platforms": [
        {
            "platform": "iphone"
        },
        {
            "platform": "ipad"
        },
        {
            "platform": "android_phone"
        },
        {
            "platform": "android_tablet"
        }
    ]
    

    So try change your pojo to something like this:

    private List platforms;
    
    public List getPlatforms(){
        return this.platforms;
    }
    
    public void setPlatforms(List platforms){
        this.platforms = platforms;
    }
    

    EDIT: you will need change mobile_networks too. Will look like this:

    private List mobile_networks;
    
    public List getMobile_networks() {
        return mobile_networks;
    }
    
    public void setMobile_networks(List mobile_networks) {
        this.mobile_networks = mobile_networks;
    }
    

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