Skip to content

Commit 165ed2e

Browse files
committed
Simplify WriteValue method to match Serialize pattern
1 parent 783f3b3 commit 165ed2e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ConvertToJsonCommandV2.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,13 +1009,10 @@ public static void WriteValue(Utf8JsonWriter writer, object? value, JsonSerializ
10091009
{
10101010
writer.WriteNullValue();
10111011
}
1012-
else if (value is PSObject psoValue)
1013-
{
1014-
System.Text.Json.JsonSerializer.Serialize(writer, psoValue, typeof(PSObject), options);
1015-
}
10161012
else
10171013
{
1018-
System.Text.Json.JsonSerializer.Serialize(writer, value, value.GetType(), options);
1014+
Type typeToProcess = value is PSObject ? typeof(PSObject) : value.GetType();
1015+
System.Text.Json.JsonSerializer.Serialize(writer, value, typeToProcess, options);
10191016
}
10201017
}
10211018
}

0 commit comments

Comments
 (0)