Skip to content

Commit 2e95743

Browse files
committed
Removed conversion of empty strings to null
1 parent d2b9742 commit 2e95743

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tools/Custom/JsonExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ namespace Microsoft.Graph.PowerShell.JsonUtilities
66
public static class JsonExtensions
77
{
88
/// <summary>
9-
/// Removes JSON properties that have a value of "defaultnull" and converts properties with values of "null" or empty strings ("") to actual JSON null values.
9+
/// Removes JSON properties that have a value of "defaultnull" and converts properties with values of "null" to actual JSON null values.
1010
/// </summary>
1111
/// <param name="jsonObject">The JObject to process and clean.</param>
1212
/// <returns>
13-
/// A JSON string representation of the cleaned JObject with "defaultnull" properties removed and "null" or empty string values converted to JSON null.
13+
/// A JSON string representation of the cleaned JObject with "defaultnull" properties removed and "null" values converted to JSON null.
1414
/// </returns>
1515
/// <example>
1616
/// JObject json = JObject.Parse(@"{""name"": ""John"", ""email"": ""defaultnull"", ""address"": ""null""}");
@@ -42,7 +42,7 @@ public static string RemoveDefaultNullProperties(this JObject jsonObject)
4242
{
4343
property.Remove();
4444
}
45-
else if (property.Value.Type == JTokenType.String && (property.Value.ToString() == "null" || property.Value.ToString() == ""))
45+
else if (property.Value.Type == JTokenType.String && (property.Value.ToString() == "null"))
4646
{
4747
property.Value = JValue.CreateNull();
4848
}

tools/Tests/JsonUtilitiesTest/JsonExtensionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void RemoveDefaultNullProperties_ShouldConvertStringNullToJsonNull()
4545

4646
// Assert
4747
Assert.Null(result["position"]?.Value<string>());
48-
Assert.Null(result["team"]?.Value<string>());
48+
Assert.Equal("",result["team"]?.ToString());
4949
Assert.Equal("Tim", result["displayname"]?.ToString());
5050
Assert.Equal(2000000, result["salary"]?.ToObject<int>());
5151
}

0 commit comments

Comments
 (0)