-Changed enum serialization in dictionary keys to use EnumMemberAttribute

This commit is contained in:
James Newton-King
2018-01-31 15:14:03 +13:00
parent e370fc2e3a
commit c90e6e871a
4 changed files with 133 additions and 5 deletions
@@ -955,7 +955,7 @@ namespace Newtonsoft.Json.Serialization
{
if (value is string)
{
return Enum.Parse(contract.NonNullableUnderlyingType, value.ToString(), true);
return EnumUtils.ParseEnum(contract.NonNullableUnderlyingType, value.ToString(), false);
}
if (ConvertUtils.IsInteger(primitiveContract.TypeCode))
{
@@ -1150,6 +1150,12 @@ namespace Newtonsoft.Json.Serialization
default:
{
escape = true;
if (primitiveContract.IsEnum && EnumUtils.TryToString(primitiveContract.NonNullableUnderlyingType, name, false, out string enumName))
{
return enumName;
}
return Convert.ToString(name, CultureInfo.InvariantCulture);
}
}