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

Enum-keyed maps bad serialization #426

Closed
aperry5544 opened this issue Apr 20, 2023 · 1 comment
Closed

Enum-keyed maps bad serialization #426

aperry5544 opened this issue Apr 20, 2023 · 1 comment

Comments

@aperry5544
Copy link

When serializing out a map that uses an enum as the key, the resulting map adds extra escaped quotes around the key name.

Example...

enum class MyEnum
{
    Value0,
    Value1
};

JSONCONS_ENUM_TRAITS(MyEnum, Value0, Value1)

std::map<MyEnum, int> my_map;
my_map[MyEnum::Value0] = 5;
my_map[MyEnum::Value1] = 10;

When serializing my_map it results in the following...

...
"my_map": {
    "\"Value0\"": 5,
    "\"Value1\"": 10
}
...

I would instead expect the output to be

...
"my_map": {
    "Value0": 5,
    "Value1": 10
}
...
@danielaparker
Copy link
Owner

Thanks for reporting this, fixed on master.

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

No branches or pull requests

2 participants