diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonNode.To.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonNode.To.cs index 8299ce7e1211..69288510c599 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonNode.To.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonNode.To.cs @@ -21,7 +21,7 @@ public string ToJsonString(JsonSerializerOptions? options = null) WriteTo(writer, options); } - return JsonHelpers.Utf8GetString(output.WrittenMemory.ToArray()); + return JsonHelpers.Utf8GetString(output.WrittenMemory.Span); } /// @@ -51,7 +51,7 @@ public override string ToString() WriteTo(writer); } - return JsonHelpers.Utf8GetString(output.WrittenMemory.ToArray()); + return JsonHelpers.Utf8GetString(output.WrittenMemory.Span); } ///