2017-04-16 41 views
0

我試圖分析在打字稿以下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); 
            } 

           ); 

回答

2

不能使用與關鍵點語法是數是JS。嘗試

response['36'] 
+0

這就是我想要的。非常感謝 –

+0

如果它解決了問題,請將答案標記爲已接受。 – unitario