我正在使用 extjs+yii 框架。我的客户端在 extjs 中,服务器端设计在 yii 框架中。所以 extjs 的表单输入通过 json 传入 yii framewok。这个 json 在 yii 控制器动作中被接受为-
public function actionSetUserAnswer()
{
$postData = json_decode(file_get_contents("php://input"), true);
$clientData = $postData['data'];
}
extjs 发送的实际 json 数据是-
'{"data":[{"optionId":"","questionId":"1","isAnswer":"","option":"Aus","media":"","keyword":"","mediaTypeId":"","id":null},{"optionId":"","questionId":"2","isAnswer":"","option":"india","media":"","keyword":"","mediaTypeId":"","id":null},{"optionId":"","questionId":"3","isAnswer":"","option":"England","media":"","keyword":"","mediaTypeId":"","id":null},{"optionId":"","questionId":"4","isAnswer":"","option":"Srilanka","media":"","keyword":"","mediaTypeId":"","id":null}]}';
因此,在 yii 中,如何使用 $clientdata 变量访问 json 的这些单独字段,例如 option、questionId 等。