打字稿解析 json 数字对象



我正在尝试在打字稿中解析以下 json 对象。对于字母表来说,它很好,但对于数字,它显示编译时错误。

{
"36": [{
    "requestId": 64992,
    "requestNumber": "PQ-17-0068112",
    "requestDate": "16-Apr-2017",
    "requestTypeId": 12,
}]

}

this._requestService.getDetails( res.requestId)
                                .subscribe(
                                    response => 
                                    {
                                        let r:any = response;
                                        //This line showing error while for alphabets its fine, for numeric its saying ',' expected
                                        console.log(response.36);
                                    }
                                );

您不能将点语法与键一起使用,键是数字是js。尝试

response['36']

最新更新