mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-21 08:21:53 +02:00
Fix exception when converting json array to C# code (#1301)
This commit is contained in:
@@ -96,13 +96,13 @@ internal static class CSharpFormatter
|
|||||||
"while"
|
"while"
|
||||||
});
|
});
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static object ConvertToAnonymousObjectDefinition(object jsonBody, int ind = 2)
|
public static object ConvertToAnonymousObjectDefinition(object jsonBody, int ind = 2)
|
||||||
{
|
{
|
||||||
var serializedBody = JsonConvert.SerializeObject(jsonBody);
|
var serializedBody = JsonConvert.SerializeObject(jsonBody);
|
||||||
using var jsonReader = new JsonTextReader(new StringReader(serializedBody));
|
using var jsonReader = new JsonTextReader(new StringReader(serializedBody));
|
||||||
jsonReader.DateParseHandling = DateParseHandling.None;
|
jsonReader.DateParseHandling = DateParseHandling.None;
|
||||||
var deserializedBody = JObject.Load(jsonReader);
|
var deserializedBody = JToken.Load(jsonReader);
|
||||||
|
|
||||||
return ConvertJsonToAnonymousObjectDefinition(deserializedBody, ind);
|
return ConvertJsonToAnonymousObjectDefinition(deserializedBody, ind);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user