Skip to content
Permalink
Browse files

Use new JSON serializer

  • Loading branch information...
davidfowl committed Feb 19, 2019
1 parent 68a54c9 commit be5d5cf06a8bd3d41218e7cb01e2c95a164992e4
Showing with 4 additions and 3 deletions.
  1. +2 −1 Samples/MyHandler.RouteProvider.cs
  2. +2 −1 Samples/MyHandler.cs
  3. +0 −1 Samples/Program.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
@@ -116,7 +117,7 @@ private async Task Post(HttpContext httpContext)
{
var handler = new MyHandler();

var bodyValue = (JValue)await _reader.ReadAsync(httpContext, typeof(JValue));
var bodyValue = (JsonDocument)await _reader.ReadAsync(httpContext, typeof(JsonDocument));

var result = handler.Post(bodyValue);
await result.ExecuteAsync(httpContext);
@@ -1,4 +1,5 @@
using System;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
@@ -65,7 +66,7 @@ public async Task<string> GetAsync([FromRoute]string name)
public string Hello() => "Hello!";

[HttpPost("/")]
public Result Post([FromBody]JToken obj)
public Result Post([FromBody]JsonDocument obj)
{
return Ok(obj);
}
@@ -14,7 +14,6 @@ public static void Main(string[] args)

public static IHost BuildWebHost(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging => logging.ClearProviders())
.ConfigureWebHostDefaults(webHostBuilder =>
{
webHostBuilder.UseStartup<Startup>();

0 comments on commit be5d5cf

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.