Your JSON response is improperly formatted. The comma following the datestamp is inside the quote, instead of outside of it:
"time":"2014-05-09 17:32:00," username":"Josue"
},
In addition, you should be using square braces to represent an array of messages. Your JSON should look like this:
{ "message": [
{
"chat":"Hello, world!",
"time":"2014-05-09 17:32:00",
"username":"Josue"
},
{
"chat":"This is my second message.",
"time":"2014-05-09 17:32:05",
"username":"Josue"
}
]
}
You can use the json_encode() function to convert a PHP array or object into a JSON string:
<?php
$my_arr = array("message" => array());
$my_arr["message"][] = array("chat" => "Hello, World!", "time" => "2014-05-09 17:32:05", "username" => "Josue");
echo json_encode($my_arr);
?>