0

Given the following object, how is the email property referenced? I've been trying variations of getresponse.partner[0].email to no avail.

{"getresponse":{"$":{"unpagedCount":"10"},"partner":[{"$":{"id":"p1e","type":"content","name":"myname","status":"active","email":"me@here.com","peopleIds":"9","personIds":"9"},"ketchup":[""]}]}}

thanks in advance! -b

Ry-
  • 209,133
  • 54
  • 439
  • 449

2 Answers2

0

$ is a valid property/variable name in Javascript. Just use it like any other property name:

let $$$ = {
  "getresponse": {
    "$": {
      "unpagedCount": "10"
    },
    "partner": [{
      "$": {
        "id": "p1e",
        "type": "content",
        "name": "myname",
        "status": "active",
        "email": "me@here.com",
        "peopleIds": "9",
        "personIds": "9"
      },
      "ketchup": [""]
    }]
  }
}

console.log($$$.getresponse.partner[0].$.email);
connexo
  • 49,059
  • 13
  • 74
  • 108
0

Just access it as a normal key in any JS object via getresponse.partner[0].$.email. Note that $ is a legal variable identifier name, as you can check in this other post.

var obj = {"getresponse":{"$":{"unpagedCount":"10"},"partner":[{"$":{"id":"p1e","type":"content","name":"myname","status":"active","email":"me@here.com","peopleIds":"9","personIds":"9"},"ketchup":[""]}]}}
var email = obj.getresponse.partner[0].$.email
console.log(email)
josepdecid
  • 1,638
  • 13
  • 24