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

why it's not possible to serialize c++11 enums directly #513

Closed
ivankarpey opened this issue Mar 17, 2017 · 4 comments · Fixed by #545
Closed

why it's not possible to serialize c++11 enums directly #513

ivankarpey opened this issue Mar 17, 2017 · 4 comments · Fixed by #545

Comments

@ivankarpey
Copy link

enum class Colors: short{ Red = 0, Green, Blue}

when trying to restore it like

Colors c = json["color"].get<Colors>() it's fails with

tools/libs/json.h:862:17: �[Kerror: static assertion failed: could not find from_json() method in T's namespace

@theodelrieu
Copy link
Contributor

Right now, only enums are supported by default, you can add a from_json method though.

We could add enum class support, to behave like regular enums by default.

@nlohmann
Copy link
Owner

If we can support this out of the box, we should do it.

@nlohmann
Copy link
Owner

nlohmann commented Apr 3, 2017

Fixed with #545.

@ivankarpey
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants