Skip to content

Commit

Permalink
Fix OData enum serialization (gustavnavar/Grid.Blazor#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavnavar committed Oct 26, 2020
1 parent fbdbeee commit afadc1c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions GridShared/Utility/JsonSerializerOptionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public static JsonSerializerOptions AddOdataSupport(this JsonSerializerOptions j
// required for Blazor WA
jsonOptions.Converters.Add(new ODataDateTimeConverter());

converters = jsonOptions.Converters.Where(r => r.CanConvert(typeof(Enum)));
if (converters != null)
for (int i = converters.Count() - 1; i >= 0; i--)
{
jsonOptions.Converters.Remove(converters.ElementAt(i));
}
jsonOptions.Converters.Add(new JsonStringEnumConverter(null));
return jsonOptions;
}
Expand Down

0 comments on commit afadc1c

Please sign in to comment.