<p>I've been using PHP for too long, but I'm new to JavaScript integration in some places. </p>

<p>I'm trying to find the fastest way to pass database information into a page where it can be modified and displayed dynamically in JavaScript. </p>

<p>Right now, I'm looking at loading a <em>JSON with PHP</em> echo statements because it's fast and effective, but I saw that I could use PHP's JSON library (PHP 5.2). </p>

<p><strong>Has anybody tried the new JSON library, and is it better than my earlier method?</strong></p>

[{'answer_id': 40613, 'author': 'John Millikin', 'author_id': 3560, 'author_profile': 'https://Stackoverflow.com/users/3560', 'pm_score': 5, 'selected': True, 'text': '<p>Use the library. If you try to generate it manually, I predict with 99% certainty that the resulting text will be invalid in some way. Especially with more esoteric features like Unicode strings or exponential notation.</p>\n'}, {'answer_id': 166701, 'author': 'Sean', 'author_id': 5446, 'author_profile': 'https://Stackoverflow.com/users/5446', 'pm_score': 2, 'selected': False, 'text': '<p>Library has worked great for me.  FWIW I needed to do this on a project with earlier version of PHP lacking JSON support.  Function below worked as a granted risky version of "json_encode" for arrays of strings.</p>\n\n<pre><code>function my_json_encode($row) {\n    $json = "{";\n        $keys = array_keys($row);\n        $i=1;\n        foreach ($keys as $key) {\n            if ($i&gt;1) $json .= \',\';\n            $json .= \'"\'.addslashes($key).\'":"\'.addslashes($row[$key]).\'"\';\n            $i++;\n        }\n    $json .= "}";\n    return $json;\n}\n</code></pre>\n'}, {'answer_id': 167164, 'author': 'SchizoDuckie', 'author_id': 18077, 'author_profile': 'https://Stackoverflow.com/users/18077', 'pm_score': 2, 'selected': False, 'text': '<p>the json_encode and json_decode methods work perfectly. Just pass them an object or an array that you want to encode and it recursively encodes them to JSON. </p>\n\n<p>Make sure that you give it UTF-8 encoded data!</p>\n'}]
['https://Stackoverflow.com/questions/40608', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4247/']