Java tutorial
//package com.java2s; //License from project: Open Source License import com.google.gson.annotations.SerializedName; public class Main { public static String serializedName(Enum anEnum) { String name = anEnum.name(); try { SerializedName serializedName = anEnum.getClass().getField(name).getAnnotation(SerializedName.class); if (serializedName != null) { name = serializedName.value(); } } catch (NoSuchFieldException ignored) { } return name; } }