Reputation: 93
I am trying to parse this JSON string -
{
"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": "[email protected]",
"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": ""
}
]
}
I am able to get all of the values using this -
Dim Att: Set Att = JSON.parse(API_Response)
Att.LeadInfo.get("FirstName")
Att.LeadInfo.get("LastName")
This works great.
My issue is how do I get the Values inside the Demographics Piece. What I am trying to get is the value "Educator" from the CATEGORY KEY.
Any ideas?
Upvotes: 0
Views: 1551
Reputation: 16682
The Demographics
object appears to be an Array of objects. You should be able to loop through using a For Each
loop to enumerate the objects in turn and check for the specific 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
...
- denotes assumed code
Upvotes: 1