简体   繁体   中英

Reset jackson JsonSerializer to default in subclass

I have a base class that looks like

@JsonSerialize(using = BaseClassSerializer.class)
public class BaseClass {
   ...
}

And a SubClass that looks like

public class SubClass extends BaseClass {
}

I do not want to use the BaseClassSerializer in SubClass , but instead revert to the default jackson serializer for SubClass . I know I can override the Serializer, but I want all the default serialization rules to work.

You can specify the None serializer on your derived class, which is Jackson's default serializer.

@JsonSerialize(using = JsonSerializer.None.class)
public class SubClass extends BaseClass {
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM