You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enum flag values not properly serialized or deserialized #130
The reason this is not working is because you are combining two enumeration together that create a value that does not exists within the enum itself. My current implement will only use the values within the implementation. If you use Read and Write flag it will generate the correct enum Value for both string and number.
In order to support this option that you want, i will have to return an int representation of the enum as it is if it cannot be found with a name within the enumeration itself.
The expected output of the issue example is "Read,Delete".
The serialization part is more challenging since we have to break down the enum value to combinations.
The ToString method of the Enum type supports flag combinations. You may take a look at their implementation [http://referencesource.microsoft.com/#mscorlib/system/enum.cs,93a0c65b8141e010] and make something similar in NetJSON.
The deserialization part is less difficult, we just split the string and match the segments to existing value representations.
Sorry for the late reply. Recently my Windows got completely broken for attempting to install the Anniversary update. I'd got to reinstall the system and everything. I will get up with the latest code when things are reinstalled.
Activity
rpgmaker commentedon Aug 26, 2016
Thanks for the find. I missed one CIL instruction :)
Can you test again
wmjordan commentedon Aug 26, 2016
It still did not work.
I'd updated the code and it still output 0 for the above statement.
wmjordan commentedon Aug 26, 2016
This issue was not the same as #131
rpgmaker commentedon Aug 26, 2016
The reason this is not working is because you are combining two enumeration together that create a value that does not exists within the enum itself. My current implement will only use the values within the implementation. If you use Read and Write flag it will generate the correct enum Value for both string and number.
In order to support this option that you want, i will have to return an int representation of the enum as it is if it cannot be found with a name within the enumeration itself.
Thanks,
wmjordan commentedon Aug 27, 2016
The expected output of the issue example is
"Read,Delete".The serialization part is more challenging since we have to break down the enum value to combinations.
The
ToStringmethod of theEnumtype supports flag combinations. You may take a look at their implementation [http://referencesource.microsoft.com/#mscorlib/system/enum.cs,93a0c65b8141e010] and make something similar in NetJSON.The deserialization part is less difficult, we just split the string and match the segments to existing value representations.
rpgmaker commentedon Aug 27, 2016
Does other json serializer output the comma delimiter value when using flags?
wmjordan commentedon Aug 27, 2016
Yes. Newtonsoft (JSON.NET) produces comma delimited results for flags with the
StringEnumConverter:rpgmaker commentedon Sep 20, 2016
Test again. It has been fixed. Sorry for the late fix and thanks again for the pull request
wmjordan commentedon Sep 20, 2016
Sorry for the late reply. Recently my Windows got completely broken for attempting to install the Anniversary update. I'd got to reinstall the system and everything. I will get up with the latest code when things are reinstalled.