Generate JSON file from Kentico page-type form fields

Tom Wisneski asked on December 1, 2020 18:53

On a website we are building out child pages of different industries/facilities, and all using a given page type. The page type has fields on the form level that we wish to grab that data and dynamically create a JSON file. So if a new child page is added, the JSON is updated with the newly added page’s info. Does anyone know of a way to generate a JSON file from Kentico fields (on the page type form fields)? Thanks all in advance for the input.

Correct Answer

Brenden Kehren answered on December 1, 2020 23:29

Check this webpart out:

https://devnet.kentico.com/old-marketplace/web-parts/webpart-to-api-converter

It will allow you to convert your output response to json when attached to a repeater web part. So what you do is place this webpart on your page template, then add another repeater webpart on your template to retrieve the data. In your transformation, set it as Text/HTML and put your json object code in there. Then go back to the wepart to API converter webpart and put the repeater's code name in the proper field and you should be able to render JSON when you navigate to that URL.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on December 1, 2020 22:20

What version are you on?

Are you using Portal Engine or MVC?

0 votesVote for this answer Mark as a Correct answer

Tom Wisneski answered on December 1, 2020 22:53 (last edited on December 1, 2020 22:58)

Hi Brenden. I guess it is portal engine (we are working in .NET Webforms not MVC). Kentico version is 11.0.48. At further thought on this, I was thinking I might be able to from the code-behind of a webpart of the parent node. Loop through the children and grab the pageType values with something like; {%CurrentDocument.GetValue("ColumnName")%}. Does this sound like a realistic way of doing it? Thanks.

0 votesVote for this answer Mark as a Correct answer

Tom Wisneski answered on December 2, 2020 14:49

Brenden -- this looks promising. I have to say I am a little confused by all this. I am more of a learner by doing. So reading a resolve initially offered does not always gel. It is not until the actual doing of it, that I grasp the full resolve. Anyways, thanks. I will circle back to this question entry once I go through these steps. Then mark it as the answer if it works as expected. Thanks! :)

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on December 2, 2020 16:12

To clarify a bit more, the webpart I referenced doesn't do anything other than convert the response output to text/json vs. text/html. The repeater simply gets the pages you're looking for and renders the markup you choose on the page.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.