It is not a good idea to judge the sample value of an enumeration based on '@JSONValue' #973
jasonkung22
started this conversation in
Ideas
Replies: 1 comment
-
This discussion has been amended at pr #977 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Most company specifications for enumerations require that you interact with the value enumValue. And '@JsonValue' only affects the serialization of the response result during enumeration parsing. Here are some ways to enumerate serialization and deserialization in different scenarios:
1, SpringMvc configuration ConverterFactory, for requestHeader, requestPath, requestParam enumeration deserialization
2. Configure the '@JsonCreator' annotation on the enumeration method to deserialize the enumeration of requestBody
3. Configure the '@JsonValue' annotation on the enumeration property or method to serialize the enumeration in response
As you can see from the above, the enumeration parameter passing process is determined by a number of factors, not just the '@JsonValue' annotation.
If different companies have different requirements for passing enumerations, you are advised to add a unified switch configuration. For example, by default, enumValue is passed, and if the switch is turned on, enumName is passed. It is also possible to standardize the company's passing of enumeration parameters, rather than the passing of enumeration in different scenarios
ConverterFactory
'@JsonCreator' or '@JsonValue'
Beta Was this translation helpful? Give feedback.
All reactions