No content to map due to end-of-input jackson parser

前端 未结 11 1961
盖世英雄少女心
盖世英雄少女心 2020-12-23 19:00

I am getting this response from the server {\"status\":\"true\",\"msg\":\"success\"}

I am trying to parse this json string using Jackson parser library

11条回答
  •  醉酒成梦
    2020-12-23 19:16

    For one, @JsonProperty("status") and @JsonProperty("msg") should only be there only when declaring the fields, not on the setters and geters.

    In fact, the simplest way to parse this would be

    @JsonAutoDetect  //if you don't want to have getters and setters for each JsonProperty
    public class StatusResponses {
    
       @JsonProperty("status")
       private String status;
    
       @JsonProperty("msg")
       private String message;
    
    }
    

提交回复
热议问题