我有以下 JSON 对象
var s = {
"TenantGroupName": "Fun Holidays",
"queue_details": [{
"queue_key": "1",
"channelId": "1",
"queue_name": "North India Travel",
"contacts": [{
"from": "meenar@interactcrm.com",
"subject": "Redemption Coupon",
"queue_time": "2:34",
"service_level_breached": "false",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}, {
"from": "sagarm@interactcrm.com",
"subject": "Redemption Coupon",
"queue_time": "2:34",
"service_level_breached": "false",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}, {
"from": "kaushalk@interactcrm.com",
"subject": "Redemption Coupon",
"queue_time": "2:34",
"service_level_breached": "false",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}, {
"from": "kaushalk@interactcrm.com",
"subject": "Redemption Coupon",
"queue_time": "8:05",
"service_level_breached": "true",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}, {
"from": "kaushalk@interactcrm.com",
"subject": "Redemption Coupon",
"queue_time": "8:34",
"service_level_breached": "true",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}]
}, {
"queue_key": "1",
"channelId": "1",
"queue_name": "South India Travel",
"contacts": []
}, {
"queue_key": "1",
"channelId": "1",
"queue_name": "Summer 2012",
"contacts": [{
"from": "meenar@interactcrm.com",
"subject": "Redemption Coupon",
"queue_time": "2:34",
"service_level_breached": "false",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}, {
"from": "raheels@interactcrm.com",
"subject": "Redemption Coupon",
"queue_time": "2:34",
"service_level_breached": "false",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}, {
"from": "sagarm@interactcrm.com",
"subject": "Redemption Coupon",
"queue_time": "2:34",
"service_level_breached": "false",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}, {
"from": "kaushalk@interactcrm.com",
"subject": "Redemption Coupon",
"queue_time": "9:34",
"service_level_breached": "true",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}]
}, {
"queue_key": "1",
"channelId": "3",
"queue_name": "Honeymoon",
"contacts": [{
"from": "Henry Williams",
"subject": "New Zealand",
"queue_time": "1:45",
"service_level_breached": "false",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}, {
"from": "Linda Simpson",
"subject": "Redemption Coupon",
"queue_time": "2:34",
"service_level_breached": "false",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}]
}, {
"queue_key": "1",
"channelId": "7",
"queue_name": "Feedback_SMS",
"contacts": [{
"from": "@sanjeev",
"subject": "Maldives",
"queue_time": "1:45",
"service_level_breached": "false",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}]
}, {
"queue_key": "1",
"channelId": "5",
"queue_name": "Feedback_Twitter",
"contacts": [{
"from": "9833202859",
"subject": "Wish to travel ...",
"queue_time": "1:45",
"service_level_breached": "false",
"cduId": "4f8b9f2322c60106c0a800bd65cc0000",
"contactPkey": "8903"
}]
}]
}
我想遍历上面的 JSON 数组。我用 Javascript 编写了以下内容
我将上面的 JSON 对象传递给 Javascript,如下所示
function CreateQueue(jString) {
var jSonString = { "MyQueue": jString };
alert(jSonString.MyQueue.length);
}
上述功能提醒:undefined
。如何遍历上面的 JSON 字符串?