Skip to content

Commit 2f33878

Browse files
authored
Leverage JsonMarshal.GetRawUtf8Value for BinatyData construction (Azure#51172)
1 parent fd9c3ff commit 2f33878

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sdk/resourcemanager/Azure.ResourceManager/src/Common/Custom/Models/ManagedServiceIdentity.Serialization.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,12 @@ internal static ManagedServiceIdentity DeserializeManagedServiceIdentity(JsonEle
263263
Dictionary<ResourceIdentifier, UserAssignedIdentity> dictionary = new Dictionary<ResourceIdentifier, UserAssignedIdentity>();
264264
foreach (var property0 in property.Value.EnumerateObject())
265265
{
266-
dictionary.Add(new ResourceIdentifier(property0.Name), ModelReaderWriter.Read<UserAssignedIdentity>(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureResourceManagerContext.Default));
266+
#if NET9_0_OR_GREATER
267+
var data = new BinaryData(JsonMarshal.GetRawUtf8Value(property0.Value).ToArray());
268+
#else
269+
var data = new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText()));
270+
#endif
271+
dictionary.Add(new ResourceIdentifier(property0.Name), ModelReaderWriter.Read<UserAssignedIdentity>(data, options, AzureResourceManagerContext.Default));
267272
}
268273
userAssignedIdentities = dictionary;
269274
continue;

0 commit comments

Comments
 (0)