我有一个向 RESTful Web 服务(通过 php 和 curl)发送请求的页面。该页面接收一个 JSON 对象作为响应。我正在尝试使用返回的数据填写一些表单字段。在我的页面上回显的对象 javascript 如下所示:
var obj = {
"NPI": [
{
"NPI": "123456789",
"EntityType": "Individual",
"IsSoleProprietor": "N",
"LastName": "Smith",
"FirstName": "John",
"MiddleName": "D",
"NameSuffix": "JR.",
"Credential": "MD",
"FirstLineMailingAddress": "PO BOX 123",
"MailingAddressCityName": "SCOTTSDALE",
"MailingAddressStateName": "AZ",
"MailingAddressPostalCode": "85255-0162",
"MailingAddressCountryCode": "US",
"MailingAddressTelephoneNumber": "888-123-4567",
"MailingAddressFaxNumber": "888-123-4567",
"FirstLinePracticeLocationAddress": "123 DR",
"SecondLinePracticeLocationAddress": "#278",
"PracticeLocationAddressCityName": "SCOTTSDALE",
"PracticeLocationAddressStateName": "AZ",
"PracticeLocationAddressPostalCode": "85266-2273",
"PracticeLocationAddressCountryCode": "US",
"PracticeLocationAddressTelephoneNumber": "888-123-4567",
"PracticeLocationAddressFaxNumber": "888-123-4567",
"EnumerationDate": "09/20/2006",
"LastUpdateDate": "02/07/2011",
"GenderCode": "M",
"Gender": "Male",
}
]
};
alert(obj.NPI.NPI);
访问这些对象属性的语法是什么。下面的警告语句不起作用(它警告“未定义”)。
谢谢您的帮助