Automagically converts json stored data to it's equivalent json.net json structure and works with dynamics.

This commit is contained in:
Shannon
2013-10-18 14:07:31 +11:00
parent c737c43fa2
commit c6431bde3f

View File

@@ -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))