好的,伙计们,我从 CakePHP 得到了这个:
array(
(int) 0 => array(
'Worker' => array(
'id' => '1',
'username' => 'davorlozic',
'first_name' => 'Davor',
'last_name' => 'Lozic',
'active' => true,
'created' => '2012-05-12 10:39:05',
'modified' => '2012-05-12 10:39:05'
)
),
(int) 1 => array(
'Worker' => array(
'id' => '2',
'username' => 'markomarkovic',
'first_name' => 'Marko',
'last_name' => 'Markovic',
'active' => true,
'created' => '2012-05-12 10:39:20',
'modified' => '2012-05-12 10:39:20'
)
所以,当我用 JSON_ENCODE 对其进行编码时,我得到了这个:
但我需要得到这个:如何?(这个形状,不是这些数据)
{
"success": true,
"Workers": [
{"id": 1, "name": 'Ed', "email": "ed@sencha.com"},
{"id": 2, "name": 'Tommy', "email": "tommy@sencha.com"}
]
}
我可以用 FIRST 数组做点什么吗?有什么变态还是什么?谢谢!:)