SerializedName (Gson 2.2.3 API)
Date: 2013-04-12

com.google.gson.annotations

## Annotation Type SerializedName

-     @Retention(value=RUNTIME)
      @Target(value=FIELD)
      public @interface SerializedName

  An annotation that indicates this member should be serialized to JSON with the provided name value as its field name.

  This annotation will override any `FieldNamingPolicy`, including the default field naming policy, that may have been set on the `Gson` instance. A different naming policy can set using the `GsonBuilder` class. See `GsonBuilder.setFieldNamingPolicy(com.google.gson.FieldNamingPolicy)` for more information.

  Here is an example of how this annotation is meant to be used:

       public class SomeClassWithFields {
         @SerializedName("name") private final String someField;
         private final String someOtherField;

         public SomeClassWithFields(String a, String b) {
           this.someField = a;
           this.someOtherField = b;
         }
       }

  The following shows the output that is generated when serializing an instance of the above example class:

       SomeClassWithFields objectToSerialize = new SomeClassWithFields("a", "b");
       Gson gson = new Gson();
       String jsonRepresentation = gson.toJson(objectToSerialize);
       System.out.println(jsonRepresentation);

       ===== OUTPUT =====
       {"name":"a","someOtherField":"b"}

  NOTE: The value you specify in this annotation must be a valid JSON field name.

  Author:
    Inderjeet Singh, Joel Leitch
  See Also:
    `FieldNamingPolicy`

- - ### Required Element Summary

    Required Elements
    Modifier and Type | Required Element and Description
    --- | ---
    `String` | `value`

- - ### Element Detail

    - #### value

          public abstract String value

      Returns:
        the desired name of the field when it is serialized

Copyright © 2008-2013 Google, Inc.. All Rights Reserved.