How to serialize transient fields using jackson?

后端 未结 3 2110
不知归路
不知归路 2021-01-02 16:09

We use JSON serialization with Jackson to expose internal state of the system for debugging properties.

By default jackson does not serialize transient fields - but

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-02 16:23

    My solution with Jackson 2.4.3:

      private static final ObjectMapper mapper =
            new ObjectMapper(){{
    
                Hibernate4Module module = new Hibernate4Module();
                module.disable(Hibernate4Module.Feature.USE_TRANSIENT_ANNOTATION);
                registerModule(module);
    
            }};
    

提交回复
热议问题