#2996 resubmitting ContentExtensions and ObjectExtensions fixes (#6473)

(cherry picked from commit 79bf9b753c)
This commit is contained in:
Benjamin Howarth
2019-09-30 16:54:28 +01:00
committed by Sebastiaan Janssen
parent d7ede1d903
commit a37b1075a1

View File

@@ -8,7 +8,10 @@ using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Xml;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Umbraco.Core.Collections;
using Formatting = Newtonsoft.Json.Formatting;
namespace Umbraco.Core
{
@@ -125,6 +128,11 @@ namespace Umbraco.Core
return Attempt.Succeed(input);
}
if (target == typeof(string) && inputType == typeof(JObject))
{
return Attempt<object>.Succeed(JsonConvert.SerializeObject(input, Formatting.None));
}
// Check for string so that overloaders of ToString() can take advantage of the conversion.
if (target == typeof(string))
{