JsonMappingException :(是NullPointerException)(通过引用链:com.domain.ProfitStrategyInputMsg [" productBasicInfo"])

时间:2015-10-13 12:09:54

标签: java json

  

org.codehaus.jackson.map.JsonMappingException :(是   java.lang.NullPointerException)(通过引用链:   com.domain.profit.ProfitStrategyInputMsg [" productBasicInfo"])

public List<ProfitStrategyInputMsg> buiInputParams() {

String paramStragetyA = "WwogICAgewogICAgICAgICJydWxlSWQiOiAxMDAxLAogICAgICAgICJwcm9maXRSdWxlIjogMSwKICAgICAgICAiY292ZXJGbGFnIjogMSwKICAgICAgICAicHJvZHVjdEJhc2ljSW5mbyI6IFsKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgImJhc2VSdWxlU2lnblR5cGUiOiAxLAogICAgICAgICAgICAgICAgImJhc2VSdWxlRWxlbWVudCI6IDEuMiwKICAgICAgICAgICAgICAgICJwcm9kdWN0SWQiOiA0NDE1NDUsCiAgICAgICAgICAgICAgICAiYm9va0NpdHkiOiBbCiAgICAgICAgICAgICAgICAgICAgIjEzMCIsCiAgICAgICAgICAgICAgICAgICAgIjEyMCIKICAgICAgICAgICAgICAgIF0sCiAgICAgICAgICAgICAgICAiZGVwYXJ0dXJlRGF0ZSI6IFsKICAgICAgICAgICAgICAgICAgICAiMjAxNS0wOS0wNSIsCiAgICAgICAgICAgICAgICAgICAgIjIwMTUtMDktMDYiLAogICAgICAgICAgICAgICAgICAgICIyMDE1LTEwLTA1IgogICAgICAgICAgICAgICAgXSwKICAgICAgICAgICAgICAgICJwcm9kdWN0VHlwZSI6IDIsCiAgICAgICAgICAgICAgICAicHJkQ2xhc3NJZCI6IDEsCiAgICAgICAgICAgICAgICAic3ViUHJkQ2xhc3NJZCI6IDEsCiAgICAgICAgICAgICAgICAiYnJhbmRUeXBlIjogMSwKICAgICAgICAgICAgICAgICJkZXN0aW5hdGlvbkNsYXNzIjogMSwKICAgICAgICAgICAgICAgICJkZXN0aW5hdGlvbkNvZGUiOiAxCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICJiYXNlUnVsZVNpZ25UeXBlIjogMiwKICAgICAgICAgICAgICAgICJiYXNlUnVsZUVsZW1lbnQiOiAzLjIsCiAgICAgICAgICAgICAgICAicHJvZHVjdElkIjogMjQxNTAxLAogICAgICAgICAgICAgICAgImRlcGFydHVyZUNpdHkiOiAxNTAwLAogICAgICAgICAgICAgICAgImJvb2tDaXR5IjogWwogICAgICAgICAgICAgICAgICAgICIxMzAiLAogICAgICAgICAgICAgICAgICAgICIxMjAiCiAgICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgICAgImRlcGFydHVyZURhdGUiOiBbCiAgICAgICAgICAgICAgICAgICAgIjIwMTUtMTAtMDEiLAogICAgICAgICAgICAgICAgICAgICIyMDE1LTExLTA2IiwKICAgICAgICAgICAgICAgICAgICAiMjAxNS0wNS0wNSIKICAgICAgICAgICAgICAgIF0sCiAgICAgICAgICAgICAgICAicHJvZHVjdFR5cGUiOiAyLAogICAgICAgICAgICAgICAgInByZENsYXNzSWQiOiAxLAogICAgICAgICAgICAgICAgInN1YlByZENsYXNzSWQiOiAxLAogICAgICAgICAgICAgICAgImJyYW5kVHlwZSI6IDEsCiAgICAgICAgICAgICAgICAiZGVzdGluYXRpb25DbGFzcyI6IDEsCiAgICAgICAgICAgICAgICAiZGVzdGluYXRpb25Db2RlIjogMQogICAgICAgICAgICB9CiAgICAgICAgXQogICAgfSwKICAgIHsKICAgICAgICAicnVsZUlkIjogMTAwMiwKICAgICAgICAicHJvZml0UnVsZSI6IDIsCiAgICAgICAgImNvdmVyRmxhZyI6IDIsCiAgICAgICAgImJhc2VSdWxlU2lnblR5cGUiOiAxLAogICAgICAgICJiYXNlUnVsZUVsZW1lbnQiOiAxLjIsCiAgICAgICAgInByb2R1Y3RCYXNpY0luZm8iOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICJiYXNlUnVsZVNpZ25UeXBlIjogMywKICAgICAgICAgICAgICAgICJiYXNlUnVsZUVsZW1lbnQiOiAzLjIsCiAgICAgICAgICAgICAgICAicHJvZHVjdElkIjogNDQxNTQ1LAogICAgICAgICAgICAgICAgImJvb2tDaXR5IjogWwogICAgICAgICAgICAgICAgICAgICIxMzAiLAogICAgICAgICAgICAgICAgICAgICIxMjAiCiAgICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgICAgImRlcGFydHVyZURhdGUiOiBbCiAgICAgICAgICAgICAgICAgICAgIjIwMTUtMDktMDUiLAogICAgICAgICAgICAgICAgICAgICIyMDE1LTA5LTA2IiwKICAgICAgICAgICAgICAgICAgICAiMjAxNS0xMC0wNSIKICAgICAgICAgICAgICAgIF0sCiAgICAgICAgICAgICAgICAicHJvZHVjdFR5cGUiOiAyLAogICAgICAgICAgICAgICAgInByZENsYXNzSWQiOiAxLAogICAgICAgICAgICAgICAgInN1YlByZENsYXNzSWQiOiAxLAogICAgICAgICAgICAgICAgImJyYW5kVHlwZSI6IDEsCiAgICAgICAgICAgICAgICAiZGVzdGluYXRpb25DbGFzcyI6IDEsCiAgICAgICAgICAgICAgICAiZGVzdGluYXRpb25Db2RlIjogMQogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAiYmFzZVJ1bGVTaWduVHlwZSI6IDEsCiAgICAgICAgICAgICAgICAiYmFzZVJ1bGVFbGVtZW50IjogMy4yLAogICAgICAgICAgICAgICAgInByb2R1Y3RJZCI6IDI0MTUwMSwKICAgICAgICAgICAgICAgICJkZXBhcnR1cmVDaXR5IjogMTUwMCwKICAgICAgICAgICAgICAgICJib29rQ2l0eSI6IFsKICAgICAgICAgICAgICAgICAgICAiMTMwIiwKICAgICAgICAgICAgICAgICAgICAiMTIwIgogICAgICAgICAgICAgICAgXSwKICAgICAgICAgICAgICAgICJkZXBhcnR1cmVEYXRlIjogWwogICAgICAgICAgICAgICAgICAgICIyMDE1LTEwLTAxIiwKICAgICAgICAgICAgICAgICAgICAiMjAxNS0xMS0wNiIsCiAgICAgICAgICAgICAgICAgICAgIjIwMTUtMDUtMDUiCiAgICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgICAgInByb2R1Y3RUeXBlIjogMiwKICAgICAgICAgICAgICAgICJwcmRDbGFzc0lkIjogMSwKICAgICAgICAgICAgICAgICJzdWJQcmRDbGFzc0lkIjogMSwKICAgICAgICAgICAgICAgICJicmFuZFR5cGUiOiAxLAogICAgICAgICAgICAgICAgImRlc3RpbmF0aW9uQ2xhc3MiOiAxLAogICAgICAgICAgICAgICAgImRlc3RpbmF0aW9uQ29kZSI6IDEKICAgICAgICAgICAgfQogICAgICAgIF0KICAgIH0KXQ==";

        List<ProfitStrategyInputMsg> params = JsonUtil.toList(
                new String(Base64.decodeBase64(paramStragetyA.getBytes())), ProfitStrategyInputMsg.class);//Exception throw  why???

        System.out.println(JsonUtil.toString(params));

        return params;
    }




public class ProfitStrategyInputMsg {
    private int coverFlag;
    private List<ProductBasicInfo> productBasicInfo;

    public int getCoverFlag() {
        return coverFlag;
    }

    public void setCoverFlag(int coverFlag) {
        this.coverFlag = coverFlag;
    }

    public List<ProductBasicInfo> getProductBasicInfo() {
        return productBasicInfo;
    }

    public void setProductBasicInfo(List<ProductBasicInfo> productBasicInfo) {
        this.productBasicInfo = productBasicInfo;
    }}

我应该如何解决这个问题?可以帮助一些人

1 个答案:

答案 0 :(得分:0)

public class ProductBasicInfo {

    private int productId;

    private List<Integer> bookCities;

    private int departureCity;

    @JsonSerialize(using = DateJsonSerializer.class)
    @JsonDeserialize(using = DateJsonDeserializer.class)
    private List<Date> departureDate;
}

变化

public class ProductBasicInfo {

    private int productId;

    private List<Integer> bookCities;

    private int departureCity;

    private List<Date> departureDate;
}