Currently I try to use reflect-cpp to serialize a struct to json and back.
enum class PlatformFlag
{
NONE = 0,
LINUX = 1 << 0,
WINDOWS = 1 << 1,
MAC = 1 << 2,
ALL = LINUX | WINDOWS | MAC
};
constexpr PlatformFlag operator&(PlatformFlag const a, PlatformFlag const b);
constexpr PlatformFlag operator|(PlatformFlag const a, PlatformFlag const b);
inline PlatformFlag& operator|=(PlatformFlag& a, PlatformFlag const b);
[...]
struct myStruct
{
PlatformFlag supportedPlatforms = PlatformFlag::NONE;
};
Serializing to json without setting a value yields something like:
{
"supportedPlatforms": ""
}
and reading it back then errors out with: Invalid enum value: ''. Must be one of [NONE, LINUX, WINDOWS, MAC]..
Am I missing something? Ideally it would either serialize to "NONE" or allow the empty string here.
Currently I try to use reflect-cpp to serialize a struct to json and back.
Serializing to json without setting a value yields something like:
{ "supportedPlatforms": "" }and reading it back then errors out with:
Invalid enum value: ''. Must be one of [NONE, LINUX, WINDOWS, MAC]..Am I missing something? Ideally it would either serialize to "NONE" or allow the empty string here.