I’m sending a string to a php script and trying to make a jsonarray out of it for processing and putting it into an sql table. I send a string from an android application to the server:
[{"name":"bob","datetime":"2012-04-14 10:40"},{"name":"Anonymous","datetime":"2012-04-14 10:40"}]
I used http://jsonlint.com/ to validate the jsonarray and it is valid. When I have the following php script:
<?php
$json_as = stripslashes($_POST["json_a"]);
//$out.=json_decode(jsoninfo);
$realjson = json_decode($json_as, true);
//print $json_as;
//echo $realjson[name];
//print $realjson[name];
print $json_as;
?>
I see get the following info in my LogCat:
The Response text is [{"name":"bob","datetime":"2012-04-14 10:40"},{"name":"Anonymous","datetime":"2012-04-14 10:40"}]
I’ve been trying to use this for reference without luck: http://webhole.net/2009/08/31/how-to-read-json-data-with-php/
But when I try to change the php script to pring something out from the variable $realjson, nothing comes back. How do I get the information out of the json string I am sending?
Sent a string in JSON format, then used the following code: