1

I have a class having following structure

public class Model {

    @SerializedName("1")
    private String name;

    //Getters and setters

}

I need to serialize this class using gson so that i will get a output like

{"name":"Lorem Ipsum"}

instead of

{"1":"Lorem Ipsum"}

I know that removing @SerializedName("1") will solve my problem. But due to some reasons I cannot change or add anything in the Model class.

So is there any way to do that without removing the @SerializedName Annotation ? I am usig Gson 2.3.1

J.R
  • 2,113
  • 19
  • 21
  • Perhaps you can change the value of the annotation at runtime? Take a look at this: http://stackoverflow.com/questions/14268981/modify-a-class-definitions-annotation-string-parameter-at-runtime – kevto Sep 29 '16 at 12:55
  • @kevto Yeah we can change the annotation, but the model is actually too complex. – J.R Sep 29 '16 at 13:04

0 Answers0