neuecc / Utf8Json

Definitely Fastest and Zero Allocation JSON Serializer for C#(NET, .NET Core, Unity, Xamarin).
MIT License
2.35k stars 266 forks source link

Invalid Guid pattern - Guid deserializer too fragile #157

Open dylanvdmerwe opened 5 years ago

dylanvdmerwe commented 5 years ago

The Guid deserializer is very fragile and needs to be more robust in how it handles Guids.

Lower case values break. Empty string breaks.

In the cases where an invalid guid is found (such as "") the deserializer should default to the default of a Guid which is Guid.Empty instead of throwing an exception.

System.ArgumentException: Invalid Guid Pattern.
   at Utf8Json.Internal.GuidBits..ctor(ArraySegment`1& utf8string)
   at Utf8Json.Formatters.GuidFormatter.Deserialize(JsonReader& reader, IJsonFormatterResolver formatterResolver)
   at Deserialize(Object[] , JsonReader& , IJsonFormatterResolver )
   at Utf8Json.JsonSerializer.Deserialize[T](Byte[] bytes, Int32 offset, IJsonFormatterResolver resolver)
   at Utf8Json.JsonSerializer.Deserialize[T](Stream stream, IJsonFormatterResolver resolver)