Convert JSON properties with under_score to DTO with lowerCamel properties using Gson
You should use LOWER_CASE_WITH_UNDERSCORES
Using this naming policy with Gson will modify the Java Field name from its camel cased form to a lower case field name where each word is separated by an underscore (_).Here's a few examples of the form "Java Field Name" ---> "JSON Field Name":
- someFieldName ---> some_field_name
- someFieldName ---> _some_field_name
- aStringField ---> a_string_field
- aURL ---> a_u_r_l
setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
The UPPER_CAMEL_CASE is used for different purpose
Using this naming policy with Gson will ensure that the first "letter" of the Java field name is capitalized when serialized to its JSON form.