@GetMapping()
public List<CarResponse> getCars() {
List<CarResponse> cars= carService.getCars();
return cars;
}
我的CarResponse看起来像:
public class CarResponse {
private int id;
private String type;
private String model;
}
[
{
"id": 1,
"type": "SUV",
"model": "Toyota"
},
{
"id": 2,
"type": "SPORT",
"model": "Porsche"
},
...
]
{
"cars": [
"car": {
"id": 1,
"type": "SUV",
"model": "Toyota"
},
"car": {
"id": 2,
"type": "SPORT",
"model": "Porsche"
},
...
]
}