Skip to content

Commit

Permalink
fixit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Nowak committed Jun 1, 2019
1 parent 9a6e558 commit c397130
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ namespace Microsoft.AspNetCore.Mvc.Rendering
{
internal class SystemTextJsonHelper : IJsonHelper
{
private readonly MvcOptions _mvcOptions;
private readonly JsonOptions _options;

public SystemTextJsonHelper(IOptions<MvcOptions> mvcOptions)
public SystemTextJsonHelper(IOptions<JsonOptions> options)
{
_mvcOptions = mvcOptions.Value;
_options = options.Value;
}

/// <inheritdoc />
public IHtmlContent Serialize(object value)
{
// JsonSerializer always encodes non-ASCII chars, so we do not need
// to do anything special with the SerializerOptions
var json = JsonSerializer.ToString(value, _mvcOptions.JsonSerializerOptions);
var json = JsonSerializer.ToString(value, _options.JsonSerializerOptions);
return new HtmlString(json);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.


using System.Text.Json.Serialization;
using Microsoft.Extensions.Options;

Expand All @@ -12,8 +10,8 @@ public class SystemTextJsonHelperTest : JsonHelperTestBase
{
protected override IJsonHelper GetJsonHelper()
{
var mvcOptions = new MvcOptions { JsonSerializerOptions = { PropertyNamingPolicy = JsonNamingPolicy.CamelCase } };
return new SystemTextJsonHelper(Options.Create(mvcOptions));
var options = new JsonOptions() { JsonSerializerOptions = { PropertyNamingPolicy = JsonNamingPolicy.CamelCase } };
return new SystemTextJsonHelper(Options.Create(options));
}
}
}

0 comments on commit c397130

Please sign in to comment.