Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SerializationFeature.WRITE_ENUM_KEYS_USING_INDEX, separate from value setting #2129

Closed
renzihui opened this issue Sep 6, 2018 · 0 comments
Milestone

Comments

@renzihui
Copy link

renzihui commented Sep 6, 2018

A new feature to "revert" behavior change in #1570

e.g. define a new SerializationFeature.WRITE_MAP_KEY_ENUMS_USING_INDEX (or whatever you think is appropriate), when it is set to false while SerializationFeature.WRITE_ENUMS_USING_INDEX is true, enum values are serialised as int (enum ordinal), enum key are serialised as string(enum name)

Why need this:

  1. Json's key is always string type, it is counterintuitive to write enum to a string of number
  2. Compatibility, many json library are unable to deserialize Map<Enum, Object> from this style {"n_index","any"}, including current Jackson see Deserialize Enums using ordinal does not work for map keys #1877
@cowtowncoder cowtowncoder changed the title SerializationFeature: Write enum using index should be able to ignore Enum key for Map Add `SerializationFeature.WRITE_ENUM_KEYS_ Sep 14, 2019
@cowtowncoder cowtowncoder changed the title Add `SerializationFeature.WRITE_ENUM_KEYS_ Add SerializationFeature.WRITE_ENUM_KEYS_USING_INDEX, separate from value setting Sep 14, 2019
@cowtowncoder cowtowncoder added this to the 2.10.0 milestone Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants