Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP json_encode not working with array of objects
    primarykey
    data
    text
    <p>I am developing php application in which i am querying database and the generated result I am sending back to html client.</p> <p>Currently I am getting array of objects which I am encoding in JSON using php function json_encode.</p> <p>But after encoding I am getting null array in my result.</p> <p>The following structure is before encoding to JSON</p> <pre><code> array(2) { [0]=&gt; object(ProductComment)#6 (2) { ["_productId":"ProductComment":private]=&gt; string(1) "1" ["_commentArray":"ProductComment":private]=&gt; array(2) { [0]=&gt; array(3) { ["comment"]=&gt; string(9) "comment 1" ["creationDate"]=&gt; string(19) "2000-02-02 00:00:00" ["userName"]=&gt; string(8) "Ashutosh" } [1]=&gt; array(3) { ["comment"]=&gt; string(13) "comment1 text" ["creationDate"]=&gt; string(19) "2012-07-31 10:20:27" ["userName"]=&gt; string(8) "Ashutosh" } } } [1]=&gt; object(ProductComment)#5 (2) { ["_productId":"ProductComment":private]=&gt; string(1) "2" ["_commentArray":"ProductComment":private]=&gt; array(2) { [0]=&gt; array(3) { ["comment"]=&gt; string(22) "comment2 product2 text" ["creationDate"]=&gt; string(19) "2012-07-31 10:48:06" ["userName"]=&gt; string(8) "Ashutosh" } [1]=&gt; array(3) { ["comment"]=&gt; string(22) "comment2 product4 text" ["creationDate"]=&gt; string(19) "2012-07-31 10:48:14" ["userName"]=&gt; string(8) "Ashutosh" } } } } </code></pre> <p>And after encoding it showing null instead of JSON. Do i need to serialize it? Anything advice will be appreciable. Thanking you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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