Gson how to get serialized name

后端 未结 2 862
执念已碎
执念已碎 2021-02-07 08:44

When we define a class with following format

public class Field {
    @SerializedName(\"name\")
    public String name;
    @SerializedName(\"category\")
    pub         


        
2条回答
  •  情话喂你
    2021-02-07 09:01

    Use reflection to retrieve the Field object you want. You can then use Field#getAnnotation(Class) to get a SerializedName instance on which you can call value() to get the name.

提交回复
热议问题