- json_decode: documentation ( source)
- print_r: documentation ( source)
- array_keys: documentation ( source)
<?php
$jsonString = <<<'EOT'
{
"result":[
{
"type":"Residence",
"street":"Piazza di Spagna",
"city":"-4:0"
},
{
"type":"Residence",
"street":"test",
"city":"-4:1"
}
]
}
EOT;
$nodeNames = array_keys(json_decode($jsonString, true)['result'][0]);
print_r($nodeNames);