This is my current PHP code
while ($row = mysql_fetch_array($result))
{
$post = new Post();
$post->setId($row['post_id']);
$post->setBody($row['post_body']);
$post->setImage($row['post_imgurl']);
$post->setStamp($row['post_stamp']);
$postList[] = $post;
}
return array('post'=> $postList);
}
and this is its output JSON. How can i make my JSON more readable like below and remove /
the character?
More readable output:
If you want readable JSON, then read it in a tool designed to present JSON for reading (such as the Chrome JSONView extension). Don't try to munge raw data into particular patterns.
That said, you can persuade PHP to munge the data in that fashion with:
json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
http://www.php.net/manual/en/function.json-encode.php
Please, take a look at the $options param of the json_encode function, I am sure, it solves your problem.