Reputation: 4473
I am sending the query with an url as POST parameters and the parameters are JSON encoded. I am new to both JSON and PHP. I have no idea how to capture the JSON encoded parameters in a PHP file and how to decode them so that I can get individual key and value pairs. Any kind of help is appreciated. In this context I would like to add one thing i.e. I am passing the parameters by Chrome POST man REST client. Thank you.
Upvotes: 1
Views: 145
Reputation: 13535
use json_decode()
if you like to have the json_decode return an object use $obj = json_decode($json_str);
and if you like to have an associative array returned $array = json_decode($json_str, true);
Upvotes: 2
Reputation: 5039
You can use file_get_contents to get the response as a one big string and then json_decode to decode the response.
http://php.net/manual/en/function.file-get-contents.php
http://php.net/manual/en/function.json-decode.php
Upvotes: 0