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

Improved Enum Support #1611

Closed
amirmasoudabdol opened this issue May 28, 2019 · 5 comments
Closed

Improved Enum Support #1611

amirmasoudabdol opened this issue May 28, 2019 · 5 comments
Labels
kind: enhancement/improvement state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated

Comments

@amirmasoudabdol
Copy link
Contributor

So, I see that we are currently supporting enum types relatively well but the documentation mentioned there are some caveats. I was wondering if it’s a good idea to use something like magic enum and achieve a safer conversion. I understand that you might not want to include another code to your code base but do you think this is something you’d like to have or you think the current method is sufficient? If you think it worth it, I maybe able to spare some time and work on it 👍🏼

@nlohmann
Copy link
Owner

That’s a C++17 library. What exactly do you have in mind?

@amirmasoudabdol
Copy link
Contributor Author

I think I'm asking for some nicer syntax for this, but I didn't consider the standard at all, my bad! Basically, I wanted to avoid defining the map macro, and see if it's possible to extract the enum names automatically, exactly what magic_enum does.

@nlohmann
Copy link
Owner

nlohmann commented Jun 1, 2019

I see. The library does not offer a unique mapping of enums, because it is up to the user to decide how to encode them (integers, strings, ???). But I think an example how to use a library like magic enum to support writing a to_json/from_json could be helpful.

@stale
Copy link

stale bot commented Jul 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Jul 1, 2019
@stale stale bot closed this as completed Jul 8, 2019
@fredemmott
Copy link

I put together the magic enum stuff here: https://github.com/fredemmott/magic_json_serialize_enum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement/improvement state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated
Projects
None yet
Development

No branches or pull requests

3 participants