You can use json_decode()
function for getting values from json.
Example:
<?php
$json = '{
"supportsUnlock" : true,
"options" : [ "email", "questions" ],
"account" : {
"name" : "a@hotmail.com"
},
"emailAddress" : "a•••••@hotmail.com",
"emailDomain" : "hotmail.com",
"rescueEmail" : false,
"forgotPasswordFlow" : true
}';
$decodeJson = json_decode($json,true);
echo "<pre>";
print_r($decodeJson);
echo $decodeJson['supportsUnlock']; // true
?>
Result of print_r():
Array
(
[supportsUnlock] => 1
[options] => Array
(
[0] => email
[1] => questions
)
[account] => Array
(
[name] => a@hotmail.com
)
[emailAddress] => a•••••@hotmail.com
[emailDomain] => hotmail.com
[rescueEmail] =>
[forgotPasswordFlow] => 1
)
Also note that, json_decode(string,true)
will return result in array format if you need result in object than you can just remove the second param of TRUE
.