Spring @RequestBody and Enum value

I’ve found what I need. http://chrisjordan.ca/post/50865405944/custom-json-serialization-for-enums-using-jackson.

It was 2 steps.

  1. Override the toString method of the Reos enum
@Override
public String toString() {
    return text;
}
  1. Annotate with @JsonCreator the fromText method of the Reos enum.
@JsonCreator
public static Reos fromText(String text)

And that’s all.

I hope this could help others facing the same problem.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)