Get enum constant from @JsonProperty value

前端 未结 1 771
自闭症患者
自闭症患者 2021-01-26 13:24

I have an Enum marked with @JsonProperty for JSON serialization/deserialization with Jackson and would like to get the enum value for a given String JsonProperty:



        
1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-26 14:09

    The desired result can be achieved through the following method:

    public static > T getEnumValueFromJsonProperty(Class enumClass, String jsonPropertyValue) {
        Field[] fields = enumClass.getFields();
        for (int i=0; i

    0 讨论(0)
提交回复
热议问题