我必须序列化用户列表。
这是我的控制器方法声明
@RequestMapping(value = "/users", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody List<UserDTO> getUsersData(Authentication authentication) {
// ....
// get users from the service layer as an ArrayList
List<UserDTO> users = userService.getUsers(authentication.getName());
return users;
}
在客户端,我得到了这个JSON:
{"ArrayList":[
{"id":8,"firstName":"User1 FN","lastName":"User1 LN"},
{"id":9,"firstName":"User2 FN","lastName":"User2 LN"}
]}
我希望收到:
{[
{"id":8,"firstName":"User1 FN","lastName":"User1 LN"},
{"id":9,"firstName":"User2 FN","lastName":"User2 LN"}
]}
我在这里想念的是什么?!