为了更容易看到:
{
"SecureZoneSubscriptionList": {
"EntityId": 51350993,
"Subscriptions": [
{
"ZoneName": "FACCM Membership",
"ZoneId": "6460",
"ExpiryDate": "9\/5\/2014 12:00:00 AM",
"SellAccess": true,
"CostPerPeriod": "0.1",
"CycleType": ""
}
]
}
}
所以你会做以下事情:
var data= {"SecureZoneSubscriptionList": {"EntityId": 51350993,"Subscriptions": [{"ZoneName": "FACCM Membership","ZoneId": "6460","ExpiryDate": "9/5/2014 12:00:00 AM","SellAccess": true,"CostPerPeriod": "0.1","CycleType": ""}]}};
var expiryDate = data.SecureZoneSubscriptionList.Subscriptions[0].ExpiryDate;
如果您从服务器响应中将其作为字符串检索,您将使用 JSON.parse 来获取对象
var data = JSON.parse('{"SecureZoneSubscriptionList": {"EntityId": 51350993,"Subscriptions": [{"ZoneName": "FACCM Membership","ZoneId": "6460","ExpiryDate": "9/5/2014 12:00:00 AM","SellAccess": true,"CostPerPeriod": "0.1","CycleType": ""}]}}');
var expiryDate = data.SecureZoneSubscriptionList.Subscriptions[0].ExpiryDate;