Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a node with a property containing some json data. Ie:
{ isThisIt: true; isThisSomethingElse: false; }
Can I query that node like this?
Model.Content.Children.Where(x => x.propertyName.isThisIt)
Hello,
You need to convert the JSON to an object before you can query it. You can use a property value converter for this. Here is an example for the Image Cropper which also stores JSON: https://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises/blob/master/Umbraco.Extensions/PropertyConverters/ImageCropperConverter.cs
Jeroen
Thanks - looks like i'm going to learn something new to day :)
Do you have an example of how you query things? Not sure if I am doing it right.
var node = new DynamicNode(1);
var children = Umbraco.Content(node.Descendants("DocTypeAlias").First().Id).Children.Where(x => x.propName.jSONProp = "something")
You shouldn't use DynamicNode because it's legacy code. Try using Umbraco.TypedContent. You can find some examples with Descendants and GetPropertyValue here: http://our.umbraco.org/documentation/Reference/Mvc/querying
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Get children where some json property is true.
I have a node with a property containing some json data. Ie:
Can I query that node like this?
Model.Content.Children.Where(x => x.propertyName.isThisIt)
Hello,
You need to convert the JSON to an object before you can query it. You can use a property value converter for this. Here is an example for the Image Cropper which also stores JSON: https://github.com/jbreuer/Hybrid-Framework-for-Umbraco-v7-Best-Practises/blob/master/Umbraco.Extensions/PropertyConverters/ImageCropperConverter.cs
Jeroen
Thanks - looks like i'm going to learn something new to day :)
Do you have an example of how you query things? Not sure if I am doing it right.
var node = new DynamicNode(1);
var children = Umbraco.Content(node.Descendants("DocTypeAlias").First().Id).Children.Where(x => x.propName.jSONProp = "something")
You shouldn't use DynamicNode because it's legacy code. Try using Umbraco.TypedContent. You can find some examples with Descendants and GetPropertyValue here: http://our.umbraco.org/documentation/Reference/Mvc/querying
Jeroen
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.