I have the following Spring @RestController method
@RequestMapping(value = "/getPeople", method = RequestMethod.GET)
public List<Person> getPeople(Model model){
List<People> people = personRepo.getAllPeople();
model.addAttribute("people", people);
return people;
}
Which returns the following to the Response Body
[
{"name":"Jim","group":1},
{"name":"Dwight","group":2},
{"name":"Stanley","group":3}
]
Can I modify this method (via the @Controller method itself, or with an AJAX request) to include additional attributes, both inside or outside of the people array, and without modifying the Person object - so that the object returned could look something like
{
"people":[
{"name":"Jim","group":1, "independentAttribute": "A"},
{"name":"Dwight","group":2, "independentAttribute": "B"},
{"name":"Stanley","group":3, "independentAttribute": "C"}
],
"extraAttributes":[
{"attribute1": 1,"attribute2": 2,"attribute3":3}
]
}
apologies if this isn't valid object/array syntax, lackadaisically threw it together.
@RestControllerthat returns the array to the Response Body - updated my question. Does that help?