title: Convert codeigniter query to json?
body: <p>I want to convert a model query to json with json_encode, it doesn't work. But with a ordinary array it does. </p>
  
  <pre><code> $arr = array("one", "two", "three");
         $data["json"] = json_encode($arr);
  </code></pre>
  
  <p>Output </p>
  
  <pre><code> &lt;?php echo "var arr=".$json.";"; ?&gt;
   var arr=["one","two","three"];
  </code></pre>
  
  <p>But when I try to convert a query codeigniter throws an error. What is it with that? 
  This is the error message: </p>
  
  <blockquote>
    <p>A PHP Error was encountered Severity:
    Warning Message: [json]
    (php_json_encode) type is unsupported,
    encoded as null</p>
  </blockquote>
  
  <p>And the converted "query" result = I mean model method is like this: </p>
  
  <pre><code>{"conn_id":null,"result_id":null,"result_array":[],"result_object":[],"current_row":0,"num_rows":9,"row_data":null} 
  </code></pre>
  
  <p>I try to do like this </p>
  
  <pre><code> $posts = $this-&gt;Posts_model-&gt;SelectAll();
         $data["posts"] = json_encode($posts); 
  </code></pre>
  
  <p>By the way, the model and method works just fine when I do it without json_encode. </p>
  
  <p>Something I'm propably doing wrong, but the question is what? </p>