Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This mapper simply uses the enum's name to serialize and deserialize any enum class without having to write a converter.
Tested with:
Serializing a
TestEnum
to JSON seems to work, but I can't be 100% sure as I can't figure out how to use this project's test framework. It did spit out proper-looking JSON when I tested it by just serializing a list of them, but I haven't been able to get the annotation processor working in my project, so I currently can't test with any custom classes.Deserializing this object:
with
![image](https://cloud.githubusercontent.com/assets/1078569/13871108/2c8550bc-ecb8-11e5-81f5-1d103eb53797.png)
LoganSquare.parseMap()
yields this:which looks good!
I mainly wanted to do this because after switching my project over from Gson, I missed the ease of how it handled Enums. This still needs work but I think it's a good starting point. Hopefully someone better versed in annotation processing can figure out a clean way to have field names overridden (like
@SerializedName
on an enum value in Gson).Thanks for the great library!