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'm trying to generate a JSON output through a view, but when I do I get this weird output in the content property, a shitload of empty JSON.
If I do the same through a regular view in a textarea I get this, which is what I expect.
When I output the Grid in JSON I do like this
@inherits Umbraco.Web.Mvc.UmbracoViewPage @{ Layout = null; IPublishedContent site = Model; var content = (site.HasValue("GridContent")) ? site.Value("GridContent") : null; var output = new { id = site.Id, order = site.SortOrder, language = site.GetCultureFromDomains(), type = site.ContentType.Alias, content = content, }; string json = Json.Encode(output); Response.ContentType = "application/json"; } @Html.Raw(json)
And in the textarea template I do like this
@inherits Umbraco.Web.Mvc.UmbracoViewPage @{ Layout = null; var content = (Model.HasValue("GridContent")) ? Model.Value("GridContent") : null; <textarea>@content</textarea> }
Any ideas on why I get this crappy output when I try in the JSON template ?
The browser is trying to format the output as it would HTML. Try using the "code" tag so it will know to ignore it.
https://www.w3schools.com/TAGs/tag_code.asp
Nope, that's not the case.
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
Render Grid in JSON gives me a weird output
I'm trying to generate a JSON output through a view, but when I do I get this weird output in the content property, a shitload of empty JSON.
If I do the same through a regular view in a textarea I get this, which is what I expect.
When I output the Grid in JSON I do like this
And in the textarea template I do like this
Any ideas on why I get this crappy output when I try in the JSON template ?
The browser is trying to format the output as it would HTML. Try using the "code" tag so it will know to ignore it.
https://www.w3schools.com/TAGs/tag_code.asp
Nope, that's not the case.
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.