【问题标题】:How to skip a map of map when deserialize from Json String to Object using object mapper使用对象映射器从 Json 字符串反序列化到对象时如何跳过映射映射
【发布时间】:2019-11-01 11:45:55
【问题描述】:

我的 POJO 中有一张地图,它始终为空。当我将 json 字符串转换为 java 对象时,由于映射,我收到了反序列化错误。那么如何在将 json 字符串转换为对象时跳过地图

【问题讨论】:

    标签: java json jackson objectmapper


    【解决方案1】:

    其中一个可能会解决问题:

    1. 您可以定义字段transient,例如:

      private transient Map<String, String> mapOfSomething;
      
    2. (或者)你可以添加@JsonIgnore注解,比如:

      @JsonIgnore
      private Map<String, String> mapOfAnotherThing;
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-27
      • 1970-01-01
      • 1970-01-01
      • 2019-09-18
      • 2014-11-02
      • 1970-01-01
      相关资源
      最近更新 更多