2

PHP で JSON データにアクセスするための構文がわかりません。私はしばらくこれをいじっています。私はJavaScriptっぽいので理解できません。

$patchData = $_POST['mydata'];
$encoded = json_encode($patchData,true);
$patchDataJSON = json_decode($encoded,true);


/* what my JSON object looks like

{"patch_name":"whatever","sound_type":{

 "synths":[
    {"synth_name":"synth1","xpos":"29.99999725818634","ypos":"10.000012516975403"},
    {"synth_name":"synth2","xpos":"1.999997252328634","ypos":"18.000012516975403"},

    ]
  }
} 

*/


$patchName = $patchDataJSON['patch_name'];  // works!
$soundType = $patchDataJSON['sound_type']; // trying to access innards of JSON object. Does not work

echo $soundType;   // Does not work.
4

1 に答える 1