{"data":[{"name":"John","sex":"M","address":{"unit":"7"}}]}
Asked
Active
Viewed 103 times
-4
-
4have you heard about json_decode? – Jaromanda X Jul 25 '19 at 03:30
-
please remove the xml and javasrcipt tags : your question is about json and php – Olivier Depriester Jul 25 '19 at 03:31
2 Answers
0
You can use json_decode()
method of PHP
.
<?php
// Store JSON data in a PHP variable
$json = '{"data":[{"name":"John","sex":"M","address":{"unit":"7"}}]}';
var_dump(json_decode($json));
?>
Live example is here
By default the json_decode() function returns an object

Shivani Sonagara
- 1,299
- 9
- 21
0
<?php
$jsonData ='{"data":[{"name":"John","sex":"M","address":{"unit":"7"}}]}';
$json_decode = json_decode($jsonData, true);
echo '<pre>';
print_r($json_decode);
echo '</pre>';
echo $json_decode['data']['0']['name'];
?>

Nidhi Gupta
- 41
- 4