How do I call the default deserializer from a custom deserializer in Jackson

前端 未结 11 1031
野趣味
野趣味 2020-11-22 14:26

I have a problem in my custom deserializer in Jackson. I want to access the default serializer to populate the object I am deserializing into. After the population I will do

11条回答
  •  孤街浪徒
    2020-11-22 15:07

    I found an answer at ans which is much more readable than the accepted answer.

        public User deserialize(JsonParser jp, DeserializationContext ctxt)
            throws IOException, JsonProcessingException {
                User user = jp.readValueAs(User.class);
                 // some code
                 return user;
              }
    

    It really doesn't get easier than this.

提交回复
热议问题