3

I am using GSON to parse a JSON file and i want to map this JSON object to a POJO class. The problem is the property name in JSON doesn't have camel-case but my java POJO object having camel-case property name.

Is there any idea without having any performance hit?

Eg: attribute name in JSON file is 'OrderNumber', But in my POJO class , Instead ordernumber, i have 'salesNumber' as attribute name. Now how can we map that OrderNumber from JSON to salesNumber of POJO class?

Thanks in advance!

user1570345
  • 193
  • 1
  • 1
  • 11

1 Answers1

1

You can use @SerializedName annotation in this case.

private class SomeObject {

  @SerializedName("OrderNumber") 
  private String salesNumber;

}
andrew
  • 6,533
  • 1
  • 22
  • 19