0

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?

1
  • Looks like Demographics is an array of objects so you would need to loop through them probably with a For Each loop. Something like For Each demo In att.Demographics then you can reference inside the loop demo.Key etc. Commented Apr 2, 2016 at 7:54

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.