From 7bb0a1a4fe8651bb564ce51a36065fab87561d7b Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Mon, 23 Nov 2015 16:44:33 -0800 Subject: [PATCH] Update `IJsonHelper` to use `IHtmlContent` - part of #3123 (2 of 5 or so) - do not expose specific `HtmlString` class --- .../Rendering/IJsonHelper.cs | 13 ++++++++----- .../ViewFeatures/JsonHelper.cs | 9 +++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/IJsonHelper.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/IJsonHelper.cs index 20c9247164..7de4f93406 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/IJsonHelper.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/Rendering/IJsonHelper.cs @@ -1,6 +1,7 @@ // 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 Microsoft.AspNet.Html.Abstractions; using Newtonsoft.Json; namespace Microsoft.AspNet.Mvc.Rendering @@ -14,15 +15,17 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Returns serialized JSON for the . /// /// The value to serialize as JSON. - /// A new containing the serialized JSON. - HtmlString Serialize(object value); + /// A new containing the serialized JSON. + IHtmlContent Serialize(object value); /// /// Returns serialized JSON for the . /// /// The value to serialize as JSON. - /// The to be used by the serializer. - /// A new containing the serialized JSON. - HtmlString Serialize(object value, JsonSerializerSettings serializerSettings); + /// + /// The to be used by the serializer. + /// + /// A new containing the serialized JSON. + IHtmlContent Serialize(object value, JsonSerializerSettings serializerSettings); } } diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/JsonHelper.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/JsonHelper.cs index 3b33478242..dc781cb9df 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/JsonHelper.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/JsonHelper.cs @@ -4,9 +4,10 @@ using System; using System.Globalization; using System.IO; -using Newtonsoft.Json; +using Microsoft.AspNet.Html.Abstractions; using Microsoft.AspNet.Mvc.Formatters; using Microsoft.AspNet.Mvc.Rendering; +using Newtonsoft.Json; namespace Microsoft.AspNet.Mvc.ViewFeatures { @@ -32,13 +33,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures } /// - public HtmlString Serialize(object value) + public IHtmlContent Serialize(object value) { return SerializeInternal(_jsonOutputFormatter, value); } /// - public HtmlString Serialize(object value, JsonSerializerSettings serializerSettings) + public IHtmlContent Serialize(object value, JsonSerializerSettings serializerSettings) { if (serializerSettings == null) { @@ -50,7 +51,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures return SerializeInternal(jsonOutputFormatter, value); } - private HtmlString SerializeInternal(JsonOutputFormatter jsonOutputFormatter, object value) + private IHtmlContent SerializeInternal(JsonOutputFormatter jsonOutputFormatter, object value) { var stringWriter = new StringWriter(CultureInfo.InvariantCulture); jsonOutputFormatter.WriteObject(stringWriter, value);