Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @JsonTypeInfo(
- use = JsonTypeInfo.Id.NAME,
- include = JsonTypeInfo.As.PROPERTY,
- property = "type") // имя поля, в которое будет записан тип
- @JsonSubTypes({
- @Type(value = Car.class, name = "car"), // синонимы для типов
- @Type(value = Truck.class, name = "truck")
- })
- public abstract class Vehicle {
- // fields, constructors, getters and setters
- }
- {
- "vehicles":
- [
- {
- "type": "car",
- "make": "Mercedes-Benz",
- "model": "S500",
- "seatingCapacity": 5,
- "topSpeed": 250.0
- },
- {
- "type": "truck",
- "make": "Isuzu",
- "model": "NQR",
- "payloadCapacity": 7500.0
- }
- ]
- }
Add Comment
Please, Sign In to add comment