diff --git a/src/Microsoft.OData.Core/Json/JsonReaderExtensions.cs b/src/Microsoft.OData.Core/Json/JsonReaderExtensions.cs
index 8b0afd714d..d5cffb4733 100644
--- a/src/Microsoft.OData.Core/Json/JsonReaderExtensions.cs
+++ b/src/Microsoft.OData.Core/Json/JsonReaderExtensions.cs
@@ -76,7 +76,7 @@ internal static void ReadEndArray(this IJsonReader jsonReader)
///
/// The to read from.
/// The property name of the current property node.
- internal static string GetPropertyName(this IJsonReader jsonReader)
+ internal static ReadOnlySpan GetPropertyName(this IJsonReader jsonReader)
{
Debug.Assert(jsonReader != null, "jsonReader != null");
Debug.Assert(jsonReader.NodeType == JsonNodeType.Property, "jsonReader.NodeType == JsonNodeType.Property");
@@ -84,7 +84,7 @@ internal static string GetPropertyName(this IJsonReader jsonReader)
// NOTE: the JSON reader already verifies that property names are strings and not null/empty
string propertyName = (string)jsonReader.GetValue();
- return propertyName;
+ return propertyName.AsSpan();
}
///
@@ -92,12 +92,12 @@ internal static string GetPropertyName(this IJsonReader jsonReader)
///
/// The to read from.
/// The property name of the property node read.
- internal static string ReadPropertyName(this IJsonReader jsonReader)
+ internal static ReadOnlySpan ReadPropertyName(this IJsonReader jsonReader)
{
Debug.Assert(jsonReader != null, "jsonReader != null");
jsonReader.ValidateNodeType(JsonNodeType.Property);
- string propertyName = jsonReader.GetPropertyName();
+ ReadOnlySpan propertyName = jsonReader.GetPropertyName();
jsonReader.ReadNext();
return propertyName;
}
@@ -260,7 +260,7 @@ internal static void SkipValue(this IJsonReader jsonReader, StringBuilder jsonRa
break;
case JsonNodeType.Property:
- jsonWriter.WriteName(jsonReader.GetPropertyName());
+ jsonWriter.WriteName(jsonReader.GetPropertyName().ToString());
break;
default:
@@ -366,7 +366,7 @@ internal static ODataValue ReadODataValue(this IJsonReader jsonReader)
while (jsonReader.NodeType != JsonNodeType.EndObject)
{
ODataProperty property = new ODataProperty();
- property.Name = jsonReader.ReadPropertyName();
+ property.Name = jsonReader.ReadPropertyName().ToString();
property.Value = jsonReader.ReadODataValue();
propertyList.Add(property);
}
@@ -481,7 +481,7 @@ internal static ValueTask ReadEndArrayAsync(this IJsonReader jsonReader)
/// The to read from.
/// A task that represents the asynchronous read operation.
/// The value of the TResult parameter contains the property name of the current property node.
- internal static Task GetPropertyNameAsync(this IJsonReader jsonReader)
+ internal static Task> GetPropertyNameAsync(this IJsonReader jsonReader)
{
Debug.Assert(jsonReader != null, "jsonReader != null");
Debug.Assert(jsonReader.NodeType == JsonNodeType.Property, "jsonReader.NodeType == JsonNodeType.Property");
@@ -490,16 +490,16 @@ internal static Task GetPropertyNameAsync(this IJsonReader jsonReader)
Task