我想要以下 JSON:
{"success": false,"errors": {"err1": "some error","err2": "another error"}}
我正在使用的代码:
$rs = array("success"=>true);
$rs['errors'][] = array("err1"=>"some error");
$rs['errors'][] = array("err2"=>"another error");
json_encode($rs);
产生以下内容:
{"success":false,"errors":[{"err1":"some error"},{"err2":"another error"}]}