In my dropwizard project I have bean classes, which are used in the Resource class like this :
@GET
@Path("/{id}")
public Response getUser(@PathParam("id") Long id) {
return Response.ok(userDAO.get(id)).build();
}
class User {
private String id;
@JsonProperty("first_name")
private String firstName;
@JsonProperty("last_name")
private String lastName;
}
Is there a way that I can add to dropwizard configuration or in the application class to tell javax to map my bean entity (user) to json using snake_case naming strategy. This will help me avoid using the @JsonProperty("first_name") annotation for every member of the class.
In the absence of the aforementioned annotation, my json looks like this :
{
"firstName": "John",
"lastName": "Doe"
}
I would rather like it to be :
{
"first_name": "John",
"last_name": "Doe"
}