diff --git a/src/HouseofCat.Serialization/JsonProvider.cs b/src/HouseofCat.Serialization/JsonProvider.cs index 3913290..26475c6 100644 --- a/src/HouseofCat.Serialization/JsonProvider.cs +++ b/src/HouseofCat.Serialization/JsonProvider.cs @@ -38,13 +38,7 @@ public TOut Deserialize(Stream inputStream) if (inputStream.Position == inputStream.Length) { inputStream.Seek(0, SeekOrigin.Begin); } - var length = (int)inputStream.Length; - var buffer = new Span(new byte[length]); - var bytesRead = inputStream.Read(buffer); - if (bytesRead == 0) throw new InvalidDataException(); - - var utf8Reader = new Utf8JsonReader(buffer); - return JsonSerializer.Deserialize(ref utf8Reader, _options); + return JsonSerializer.Deserialize(inputStream, _options); } public async Task DeserializeAsync(Stream inputStream) @@ -63,7 +57,7 @@ public ReadOnlyMemory Serialize(TIn input) public void Serialize(Stream outputStream, TIn input) { - JsonSerializer.Serialize(new Utf8JsonWriter(outputStream), input, _options); + JsonSerializer.Serialize(outputStream, input, _options); outputStream.Seek(0, SeekOrigin.Begin); }