I'm trying to parse a simple JSON
string, but I'm not used to do it from PHP
. To do my testo I've wrote a js page where the data is created, sent to php page and returned back to do some test.
how can I access to json data from PHP and return them back?
the string from jQuery:
var json_str = '{"id_list":[{"id":"2","checked":"true"},{"id":"1","checked":"false"}]}';
/*'{
"id_list": [
{
"id": "2",
"checked": "true"
},{
"id": "1",
"checked": "false"
}
]
}'*/
$.post ("php_json_parser.php", { data_to_send:json_str }, function (data_back) {
alert (data_back);
});
php page:
<?php
$data_back = json_decode (stripslashes($_REQUEST['data_to_send']), true);
print $data_back->{'id_list'[0]["id"]}; //??? how can I access to properties?
?>