tag:help-archives.hannonhill.com,2010-02-09:/discussions/how-do-i/20628-output-data-from-datadefinition-to-jsonCascade CMS: Discussion 2015-12-22T19:58:37Ztag:help-archives.hannonhill.com,2010-02-09:Comment/386159722015-12-03T19:46:40Z2015-12-03T19:46:40Zoutput data from DataDefinition to json<div><p>Hi Simon,</p>
<p>Currently, outputting XML as JSON is a bit more manual than
simply dumping serialized XML. To summarize, you would need to loop
over all of the XML elements and generate valid JSON markup using
the node name and their escaped value. Additionally, you would need
to use some recursion to handle any nested groups.</p>
<p>If you are using XSLT, I was able to find <a href="http://help.hannonhill.com/discussions/xslt-formats/167-json-w-quotes-in-string#comment_14965490">
this related discussion</a> which can provide an example for
staters. It's a little older, so you'll want to replace
<code>#START-ROOT-CODE</code> and <code>#END-ROOT-CODE</code> with
the newer <code>#protect-top</code> code section. With that Format,
you would set up your output to use the JSON type and have a
template that looks like the following:</p>
<pre>
<code><!--#cascade-skip--><pass-through><system-region name="DEFAULT"/></pass-through></code>
</pre>
<p>To summarize, the <code><pass-through></code> element
within the Template will allow you to work around the "root node"
requirement for valid XML, and the <code>#cascade-skip</code> will
remove that element on render. The <code>#protect-top</code> within
your Format will move your content to the very top, resulting in a
plain text file being generated.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/386159722015-12-07T12:10:38Z2015-12-07T12:10:38Zoutput data from DataDefinition to json<div><p>Ok thanks for that, I think that's doable. So the plain text
file of json that is generated - I need to export that to the file
system so it can be called from a url? Or does this all happen on
the fly?</p>
<p>Thanks.</p></div>sandertag:help-archives.hannonhill.com,2010-02-09:Comment/386159722015-12-07T12:44:05Z2015-12-07T12:44:05Zoutput data from DataDefinition to json<div><p>Not a problem at all, Simon, let me know if you run into any
roadblocks while writing the Format and I'd be happy to try and
help out.</p>
<blockquote>
<p>So the plain text file of json that is generated - I need to
export that to the file system so it can be called from a url? Or
does this all happen on the fly?</p>
</blockquote>
<p>One your page output is generating the desired JSON, it would be
published to your Destinations (ie web servers) as any other page
would so it is publicly accessible.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffith