Guest User

Untitled

a guest
Mar 24th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. @JsonTypeInfo(
  2. use = JsonTypeInfo.Id.NAME,
  3. include = JsonTypeInfo.As.PROPERTY,
  4. property = "type") // имя поля, в которое будет записан тип
  5. @JsonSubTypes({
  6. @Type(value = Car.class, name = "car"), // синонимы для типов
  7. @Type(value = Truck.class, name = "truck")
  8. })
  9. public abstract class Vehicle {
  10. // fields, constructors, getters and setters
  11. }
  12.  
  13. {
  14. "vehicles":
  15. [
  16. {
  17. "type": "car",
  18. "make": "Mercedes-Benz",
  19. "model": "S500",
  20. "seatingCapacity": 5,
  21. "topSpeed": 250.0
  22. },
  23.  
  24. {
  25. "type": "truck",
  26. "make": "Isuzu",
  27. "model": "NQR",
  28. "payloadCapacity": 7500.0
  29. }
  30. ]
  31. }
Add Comment
Please, Sign In to add comment