我正在尝试解析此JSON字符串 -
{
"Success": true,
"Messages": [],
"LeadInfo": {
"LeadID": "21941873",
"CapturedDate": "4/29/2015 9:39:33 AM",
"CapturedBy": "Dev Kit 15231929",
"ConnectKey": "1001",
"FirstName": "DEMO_1001",
"LastName": "ATTENDEE_1001",
"Title": "",
"Company": "DEMOCOMPANY_1001",
"Company2": "",
"Address": "145861 N Market Street",
"Address2": "",
"Address3": "",
"City": "Frederick",
"StateCode": "MD",
"ZipCode": "21701",
"CountryCode": "United States",
"Email": "1001@experient-inc.com",
"Phone": "1234567890",
"PhoneExtension": "1111",
"Fax": "9876543210",
"Notes": ""
},
"Demographics": [
{
"Key": "CATEGORY",
"Description": "Category/Classification",
"Value": "Educator"
},
{
"Key": "SPECIALTY",
"Description": "Specialty",
"Value": "General"
},
{
"Key": "ADDTYPECODE",
"Description": "ADDRESS TYPE",
"Value": ""
}
]
}
我可以使用它来获取所有值 -
Dim Att: Set Att = JSON.parse(API_Response)
Att.LeadInfo.get("FirstName")
Att.LeadInfo.get("LastName")
这很有效。
我的问题是我如何获得人口统计学片段中的值。我想要得到的是来自CATEGORY KEY的价值“教育者”。
有什么想法吗?
答案 0 :(得分:0)
Demographics
对象似乎是一个对象数组。您应该能够循环使用For Each
循环来依次枚举对象并检查特定的Key
。
Dim demo, key, desc, val
'...
For Each demo In Att.Demographics
key = demo.Get("Key")
desc = demo.Get("Description")
val = demo.Get("Value")
If key = "CATEGORY" Then Exit For
Next
...
- 表示假定代码