PHPでこれに似たjsonオブジェクトを作成するにはどうすればよいですか?
{
"employees": [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName":"Jones" }
]
}
配列を作成し、それをjson_encodeに渡します
$stuff = array(
'employees' => array(
array('firstName' => 'John', 'lastName' => 'Doe'),
....
)
);
echo json_encode($stuff);