-4
{"data":[{"name":"John","sex":"M","address":{"unit":"7"}}]}
jeffjenx
  • 17,041
  • 6
  • 57
  • 99
Jack THOR
  • 1
  • 2

2 Answers2

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'];
?>