-1
다음 JSON (유효성을 검사하고 올바른지 확인)이 있으며 주소 수를 얻으려고합니다. 나는JSON의 주소 수는 얼마입니까?
var location = req.body;
내가
{ AddressValidateRequest:
{ '-USERID': 'xxxxxxxxxxx',
Address: [ [Object], [Object], [Object] ] } }
을받을 수 있나요 때 어떻게 주소의 수를받을 수 있나요?
{
"AddressValidateRequest": {
"-USERID": "xxxxxxxxxxx",
"Address": [
{
"-ID": "0",
"FirmName": "firmname",
"Address1": "address1here",
"Address2": "13 infinite loop",
"City": "new york",
"State": "NY",
"Zip5": "zip5here",
"Zip4": "zip4here"
},
{
"-ID": "1",
"FirmName": "firmhere",
"Address1": "address1here",
"Address2": "1 Smith Ct ",
"City": "San Predo",
"State": "CA",
"Zip5": "ziphere",
"Zip4": "ziphere1"
},
{
"-ID": "1",
"FirmName": "firmhere",
"Address1": "address1here",
"Address2": "12 John Rd ",
"City": "Newark",
"State": "PA",
"Zip5": "ziphere",
"Zip4": "ziphere1"
}
]
}
}
사실 그것은 작동하지 않았지만 내가 req.body를 위치 I에 할당 했으므로 않았다 'console.log (location.AddressValidateRequest.Address.length);' 그리고 효과가있었습니다. 귀하의 제안을 시도하고 오류가 발생했습니다 : "ReferenceError : 요청이 정의되지 않았습니다.
at Object.handle" – ConfusedDeer
답변을 location.AddressValidateRequest.Address.length로 업데이트하십시오. 대답. – ConfusedDeer
req.body.AddressValidateRequest.Address.length가 작동했지만 – ConfusedDeer