Skip to content

Commit 81f2120

Browse files
Microsoft Graph DevX ToolingMicrosoft Graph DevX Tooling
authored andcommitted
Fixed formatting
1 parent aedcfa0 commit 81f2120

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

tools/Custom/JsonExtensions.cs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -77,38 +77,38 @@ private static JToken ProcessToken(JToken token)
7777
// Remove the object itself if ALL properties are removed (empty object)
7878
return jsonObject.HasValues ? jsonObject : null;
7979
}
80-
else if (token is JArray jsonArray)
81-
{
82-
for (int i = jsonArray.Count - 1; i >= 0; i--)
80+
else if (token is JArray jsonArray)
8381
{
84-
JToken item = jsonArray[i];
85-
86-
// Process nested objects/arrays inside the array
87-
if (item is JObject || item is JArray)
82+
for (int i = jsonArray.Count - 1; i >= 0; i--)
8883
{
89-
JToken cleanedItem = ProcessToken(item);
84+
JToken item = jsonArray[i];
9085

91-
if (ShouldRemove(cleanedItem))
86+
// Process nested objects/arrays inside the array
87+
if (item is JObject || item is JArray)
9288
{
93-
jsonArray.RemoveAt(i); // Remove empty or unnecessary items
89+
JToken cleanedItem = ProcessToken(item);
90+
91+
if (ShouldRemove(cleanedItem))
92+
{
93+
jsonArray.RemoveAt(i); // Remove empty or unnecessary items
94+
}
95+
else
96+
{
97+
jsonArray[i] = cleanedItem; // Update with cleaned version
98+
}
9499
}
95-
else
100+
else if (item.Type == JTokenType.String && item.ToString().Equals("null", StringComparison.Ordinal))
96101
{
97-
jsonArray[i] = cleanedItem; // Update with cleaned version
102+
jsonArray[i] = JValue.CreateNull(); // Convert "null" string to JSON null
103+
}
104+
else if (item.Type == JTokenType.String && item.ToString().Equals("defaultnull", StringComparison.Ordinal))
105+
{
106+
jsonArray.RemoveAt(i); // Remove "defaultnull" entries
98107
}
99108
}
100-
else if (item.Type == JTokenType.String && item.ToString().Equals("null", StringComparison.Ordinal))
101-
{
102-
jsonArray[i] = JValue.CreateNull(); // Convert "null" string to JSON null
103-
}
104-
else if (item.Type == JTokenType.String && item.ToString().Equals("defaultnull", StringComparison.Ordinal))
105-
{
106-
jsonArray.RemoveAt(i); // Remove "defaultnull" entries
107-
}
108-
}
109109

110-
return jsonArray.HasValues ? jsonArray : null;
111-
}
110+
return jsonArray.HasValues ? jsonArray : null;
111+
}
112112

113113
return token;
114114
}
@@ -201,4 +201,3 @@ private static void ProcessBody(JToken token)
201201
}
202202
}
203203
}
204-

0 commit comments

Comments
 (0)