Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>PHP offers <code>json_encode()</code>, see <a href="http://at.php.net/manual/de/function.json-encode.php" rel="nofollow">the php manual on json_decode()</a>.<br> If you're receiving JSON values you can decode them with <code>json_decode()</code>.<br> Those function require the JSON-extension installed (which is a default).</p> <p>JSONT is a client side library to transform JSON data into HTML, to use it your client webpage has to implement <a href="http://goessner.net/download/prj/jsont/jsont.js" rel="nofollow">http://goessner.net/download/prj/jsont/jsont.js</a>. You just need to feed it with an json object containing the information.</p> <p>For example if you want to add an link to this question:</p> <pre><code>&lt;div id="jsont-space"&gt; &lt;?php $jsontLink = new stdClass(); $jsontLink-&gt;uri = 'http://stackoverflow.com/questions/4656055/json-transformation-for-php'; $jsontLink-&gt;title = 'Question on Stackoverflow about: JSON transformation for PHP'; ?&gt; &lt;script type="text/javascript"&gt; var transforms = { "self": "&lt;a href=\"{uri}\" title='{title}'&gt;{$.title}&lt;/a&gt;" }; var data = &lt;?php echo json_encode($jsontLink); ?&gt;; document.write(jsonT(data, transforms)); &lt;/script&gt; &lt;/div&gt; </code></pre> <p>This is of course something very quick&amp;dirty. But it should explain the whole variant of </p> <ul> <li>defining the data</li> <li>defining transformations</li> <li>applying those to a page</li> </ul> <p>here are <a href="http://goessner.net/download/prj/jsont/jsont-test.html" rel="nofollow">some additional examples on JSONT</a> (look @ source)</p> <p><strong>Edit:</strong><br> Added information about JSONT &amp; implementation example</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload