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 need some json for a typeahead feature, and im a bit stucking in some nested listing of parameters.
I need json of this structure:
{"items":[ { "name":"Organisationen", "url":"/om-uch/organisationen/", "value":"Organisationen", "tokens": [ "i", "need", "help" ] } ]}
I have this:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ var items = new List<dynamic>(); var thepages = CurrentPage.AncestorOrSelf(1).Descendants("Indholdsside"); foreach(var page in thepages) { items.Add(new { name = page.Name, url = page.Url, value = page.Name }); } var o = new { items = items }; string json = Json.Encode(o); Response.ContentType = "application/json"; } @Html.Raw(json)
I need a bit of help getting the "tokens" rendered inside the json.They are a comma separated string from an input field on the doc type.
Ok, so it wasnt so hard :)
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ var items = new List<dynamic>(); var thepages = CurrentPage.AncestorOrSelf(1).Descendants("Praktikplads"); foreach(var page in thepages) { var searchterms = page.Name; if (page.HasValue("interneSoegeord")){ searchterms = page.Name + "," + page.interneSoegeord ; } items.Add(new { name = page.Name, url = page.Url, tokens = searchterms.Split(',') }); } var o = new { items = items }; string json = Json.Encode(o); Response.ContentType = "application/json"; } @Html.Raw(json)
But i have another issue. I need my json to start with a [ and not "{"items":"How do i get rid of those {"items": }
Another simple solution :)
string json =Json.Encode(items);
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
list nodes as json with parameters
I need some json for a typeahead feature, and im a bit stucking in some nested listing of parameters.
I need json of this structure:
I have this:
I need a bit of help getting the "tokens" rendered inside the json.
They are a comma separated string from an input field on the doc type.
Ok, so it wasnt so hard :)
But i have another issue. I need my json to start with a [ and not "{"items":"
How do i get rid of those {"items": }
Another simple solution :)
is working on a reply...