@ Getter
@ AllArgsConstructor
@ JsonDeserialize (using=EnumDeserializer. Class)
@ JsonSerialize (using=EnumSerializer. Class)
Enum HttpResult {
Success (200, "Success"),//pay attention to the comma
Failed (500, "Failed");//note that semicolon
private int code;
Private String status;
}
This configuration complains
The Exception in the thread "main" com. Fasterxml. Jackson. Databind. JsonMappingException: Class com. Fasterxml. Jackson. Databind. Ser. STD. EnumSerializer has no default (no arg) constructor
Hope to get the
{" code ": 500, the" status ":" Failed "} so that the output of the
Could you tell me how to realize the enum Jackson json serialization and deserialization
CodePudding user response:
@ NoArgsConstructor class upon thisCodePudding user response:
Json data conversion usually use ordinary objects instead of enumCodePudding user response: