Hi,
I have a controller method called getAlbums() which is actually called via Ajax.
This works perfectly and returns the collection of albums as a JSON encoded string.public @ResponseBody Collection<Album> getAlbums(HttpServletRequest request,@RequestParam int start,@RequestParam int limit) {
Collection<Album> albums = null;
albums = albumDao.findAlbums(1,start,limit);
return albums;
}
However, what I actually need is to return an additional property in the JSON response which indicates the total number of albums for that user in the database, this property should be at the beginning or end of the JSON response and is used for paging purposes on the front end.
for example: { "totalAlbums":10, albums[{ ... }] }
How do I go about doing this as if I change the return type to String then I don't get a JSON response any longer.
Is there a way to add attributes/fields like in the example above to a already formatted JSON response?
Thanks,
Paul.


Reply With Quote
