Automagically converts json stored data to it's equivalent json.net json structure and works with dynamics.
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user