Interface FieldNamingStrategy

  • All Known Implementing Classes:
    FieldNamingPolicy

    public interface FieldNamingStrategy
    A mechanism for providing custom field naming in Gson. This allows the client code to translate field names into a particular convention that is not supported as a normal Java field declaration rules. For example, Java does not support "-" characters in a field name.
    Since:
    1.3
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default java.util.List<java.lang.String> alternateNames​(java.lang.reflect.Field f)
      Returns alternative names for this field when it is being deserialized.
      java.lang.String translateName​(java.lang.reflect.Field f)
      Translates the field name into its JSON field name representation.
    • Method Detail

      • translateName

        java.lang.String translateName​(java.lang.reflect.Field f)
        Translates the field name into its JSON field name representation.
        Parameters:
        f - the field object that we are translating
        Returns:
        the translated field name.
        Since:
        1.3
      • alternateNames

        default java.util.List<java.lang.String> alternateNames​(java.lang.reflect.Field f)
        Returns alternative names for this field when it is being deserialized. This is similar to SerializedName.alternate().
        Parameters:
        f - the field object
        Returns:
        the list of alternative field names.
        Since:
        2.13.1