Using jackson for serialization / deserialization
<dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-core-asl</artifactId>
        <version>1.9.13</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.13</version>
    </dependency>
Spring Controller Class
@RequestMapping(value = { "/updateUsers" }, method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public ResponseJson updateUsers(@RequestBody UserProfileBean userProfileBean,  HttpSession reqSession)
    {
//do something
}
Bean Class
public class UserProfileBean {
    List<SearchContactDetails> users;
    public List<SearchContactDetails> getUsers() {
        return users;
    }
    public void setUsers(List<SearchContactDetails> users) {
        this.users = users;
    }
}
public class SearchContactDetails {
    private String userName;
    private String userId;
//getters and setters
    }
Now if i am calling this url from my UI- browser but i am getting a bad request -400
inspecting the JSON which im sending to controller it missed the userName key
so this works if i pass both the parameters in request body
{
  "users": [
    {
      "userName": "test1",
      "userId": "1"
    },
    {
      "userName": "test2",
      "userId": "2"
    }
  ]
}
Fails 400 bad request if i miss the userName, username is an optional field for me but some how it wont't work, is there a way we can declare these fields optional
{
  "users": [
    {
      "userId": "1"
    },
    {
      "userId": "2"
    }
  ]
}
