From c6431bde3ff2161e0ae8403cafb9e6ca1f4155b9 Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 18 Oct 2013 14:07:31 +1100 Subject: [PATCH] Automagically converts json stored data to it's equivalent json.net json structure and works with dynamics. --- .../PublishedContent/PublishedPropertyType.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs index ae778bb207..5e72cb6b2f 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedPropertyType.cs @@ -4,6 +4,8 @@ using System.Globalization; using System.Linq; using System.Xml.Linq; using System.Xml.XPath; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Umbraco.Core.Dynamics; using Umbraco.Core.PropertyEditors; @@ -186,6 +188,20 @@ namespace Umbraco.Core.Models.PublishedContent if (bool.TryParse(stringSource, out b)) return b; + //try json - expensive + if (stringSource.DetectIsJson()) + { + try + { + var obj = JsonConvert.DeserializeObject(stringSource); + return obj; + } + catch + { + //swallow, continue trying other things + } + } + // try xml - that is expensive, performance-wise XElement elt; if (XmlHelper.TryCreateXElementFromPropertyValue(stringSource, out elt))