typescript에서 다음 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']
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다