Skip to content

Commit 971bb7f

Browse files
Microsoft Graph DevX ToolingMicrosoft Graph DevX Tooling
authored andcommitted
maintained parsing of values to JsonToken because it unescapes the values
1 parent 41fac07 commit 971bb7f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/Custom/JsonExtensions.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public static string ReplaceAndRemoveSlashes(this string body)
131131
ProcessBody(jsonToken);
132132

133133
// Return cleaned JSON string
134-
return JsonConvert.SerializeObject(jsonToken, Formatting.None, new PreserveStringConverter());
134+
return JsonConvert.SerializeObject(jsonToken, Formatting.None);
135135
}
136136
catch (Newtonsoft.Json.JsonException)
137137
{
@@ -154,7 +154,8 @@ private static void ProcessBody(JToken token)
154154
string stringValue = value.ToString();
155155
try
156156
{
157-
property.Value = stringValue; // Replace with unescaped JSON object
157+
JToken parsedValue = JToken.Parse(stringValue);
158+
property.Value = parsedValue; // Replace with unescaped JSON object
158159
ProcessBody(stringValue); // Recursively process
159160
}
160161
catch (Newtonsoft.Json.JsonException)
@@ -180,7 +181,8 @@ private static void ProcessBody(JToken token)
180181
string stringValue = value.ToString();
181182
try
182183
{
183-
jsonArray[i] = stringValue; // Replace with unescaped JSON object
184+
JToken parsedValue = JToken.Parse(stringValue);
185+
jsonArray[i] = parsedValue; // Replace with unescaped JSON object
184186
ProcessBody(stringValue); // Recursively process
185187
}
186188
catch (Newtonsoft.Json.JsonException)

0 commit comments

Comments
 (0)