CodeIgniter Forums
JSON library - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: JSON library (/thread-8695.html)

JSON library - El Forum - 05-27-2008

I'm using the JSON library found on the CI wiki, but I've run into a problem. When a user posts a news article, I take all of the data and convert it into JSON, which I then store in my database:

$content = $this->json->encode(array($user_id, $content, $type, $timestamp));

This works fine unless the $content string contains a quotation mark ('). I'm guessing this is because JSON uses them to separate data. Here's the error I get:

Quote:Call to a member function load() on a non-object in system/database/DB_driver.php

If I remove the json->encode call, and just store the $content as standard text, everything is peachy. I tried a few things to remedy the problem, including running $content through: htmlentities and addslashes, all to no avail.

Any suggestions?