BodyAsJsonIndented (#113)

This commit is contained in:
Stef Heyenrath
2018-03-28 09:51:01 +02:00
parent bdb79aec95
commit df4a1f628a
10 changed files with 107 additions and 40 deletions

View File

@@ -87,7 +87,8 @@ namespace WireMock.Owin
if (responseMessage.BodyAsJson != null)
{
string jsonBody = JsonConvert.SerializeObject(responseMessage.BodyAsJson, new JsonSerializerSettings { Formatting = Formatting.None, NullValueHandling = NullValueHandling.Ignore });
Formatting formatting = responseMessage.BodyAsJsonIndented == true ? Formatting.Indented : Formatting.None;
string jsonBody = JsonConvert.SerializeObject(responseMessage.BodyAsJson, new JsonSerializerSettings { Formatting = formatting, NullValueHandling = NullValueHandling.Ignore });
using (var writer = new StreamWriter(response.Body, responseMessage.BodyEncoding ?? _utf8NoBom))
{
await writer.WriteAsync(jsonBody);