Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public override T FromStream<T>(Stream stream)

if (CosmosObject.TryCreateFromBuffer(content, out CosmosObject cosmosObject))
{
return System.Text.Json.JsonSerializer.Deserialize<T>(cosmosObject.ToString(), this.jsonSerializerOptions);
IJsonWriter jsonWriter = JsonWriter.Create(JsonSerializationFormat.Text);
cosmosObject.WriteTo(jsonWriter);
return System.Text.Json.JsonSerializer.Deserialize<T>(jsonWriter.GetResult().Span, this.jsonSerializerOptions);
}
else
{
Expand Down Expand Up @@ -133,8 +135,7 @@ public override string SerializeMemberName(MemberInfo memberInfo)
private T DeserializeStream<T>(
Stream stream)
{
using StreamReader reader = new (stream);
return System.Text.Json.JsonSerializer.Deserialize<T>(reader.ReadToEnd(), this.jsonSerializerOptions);
return System.Text.Json.JsonSerializer.Deserialize<T>(stream, this.jsonSerializerOptions);
}
}
}
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

#### Other Changes

- Performance: Avoid full-document UTF-16 `string` allocation and redundant UTF-8↔UTF-16 transcoding in `CosmosSystemTextJsonSerializer` read paths (binary and text). UTF-8 bytes are now fed directly into `Utf8JsonReader` via `JsonSerializer.Deserialize<T>(Stream, ...)` and `Deserialize<T>(ReadOnlySpan<byte>, ...)`, reducing CPU, memory bandwidth, and GC pressure (including LOH pressure for larger documents).

### <a name="3.61.0-preview.0"/> [3.61.0-preview.0](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.61.0-preview.0) - 2026-5-18

#### Features Added
Expand Down