Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 6c53784

Browse files
committed
React to aspnet/Mvc#4834
- JSON now serialized with camel case - another part of fix for aspnet/Mvc#4283
1 parent 95edef1 commit 6c53784

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

samples/MusicStore.Spa/Infrastructure/SmartJsonResult.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using System;
21
using System.Threading.Tasks;
32
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc.Formatters;
44
using Newtonsoft.Json;
55

66
namespace Microsoft.AspNetCore.Mvc
@@ -9,7 +9,6 @@ public class SmartJsonResult : ActionResult
99
{
1010
public SmartJsonResult() : base()
1111
{
12-
1312
}
1413

1514
public JsonSerializerSettings Settings { get; set; }
@@ -29,8 +28,8 @@ public override Task ExecuteResultAsync(ActionContext context)
2928
// context.HttpContext.Response.ContentType = "application/json";
3029
// context.HttpContext.Response.ContentEncoding = Encoding.UTF8;
3130
//}
32-
33-
return context.HttpContext.Response.WriteAsync(JsonConvert.SerializeObject(Data, Settings ?? new JsonSerializerSettings()));
31+
var settings = Settings ?? JsonSerializerSettingsProvider.CreateSerializerSettings();
32+
return context.HttpContext.Response.WriteAsync(JsonConvert.SerializeObject(Data, settings));
3433
}
3534
}
3635
}

test/FunctionalTests/MvcTests/FormatFilterSampleTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public async Task FormatFilter_NoExtensionInRequest()
3030

3131
// Assert
3232
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
33-
Assert.Equal(@"{""SampleInt"":5}", await response.Content.ReadAsStringAsync());
33+
Assert.Equal(@"{""sampleInt"":5}", await response.Content.ReadAsStringAsync());
3434
}
3535

3636
[Fact]
@@ -41,7 +41,7 @@ public async Task FormatFilter_ExtensionInRequest_Default()
4141

4242
// Assert
4343
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
44-
Assert.Equal(@"{""SampleInt"":5}", await response.Content.ReadAsStringAsync());
44+
Assert.Equal(@"{""sampleInt"":5}", await response.Content.ReadAsStringAsync());
4545
}
4646

4747
[Fact]
@@ -56,7 +56,7 @@ public async Task FormatFilter_ExtensionInRequest_Optional()
5656

5757
// Assert
5858
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
59-
Assert.Equal(@"{""SampleInt"":0}", await response.Content.ReadAsStringAsync());
59+
Assert.Equal(@"{""sampleInt"":0}", await response.Content.ReadAsStringAsync());
6060
}
6161

6262
[Fact]
@@ -107,7 +107,7 @@ public async Task FormatFilter_And_ProducesFilter_Match()
107107

108108
// Assert
109109
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
110-
Assert.Equal(@"{""SampleInt"":5}", await response.Content.ReadAsStringAsync());
110+
Assert.Equal(@"{""sampleInt"":5}", await response.Content.ReadAsStringAsync());
111111
}
112112

113113
[Fact]

test/FunctionalTests/MvcTests/JsonPatchSampleTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public async Task JsonPatch_JsonConverterOnProperty_Success()
301301
// Assert
302302
var body = await response.Content.ReadAsStringAsync();
303303
dynamic d = JObject.Parse(body);
304-
Assert.Equal("OrderTypeSetInConverter", (string)d.Orders[2].OrderType);
304+
Assert.Equal("OrderTypeSetInConverter", (string)d.orders[2].orderType);
305305
}
306306

307307
[Fact]
@@ -324,7 +324,7 @@ public async Task JsonPatch_JsonConverterOnClass_Success()
324324
// Assert
325325
var body = await response.Content.ReadAsStringAsync();
326326
dynamic d = JObject.Parse(body);
327-
Assert.Equal("CategorySetInConverter", (string)d.ProductCategory.CategoryName);
327+
Assert.Equal("CategorySetInConverter", (string)d.productCategory.CategoryName);
328328

329329
}
330330
}

0 commit comments

Comments
 (0)