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-
  • 218,210
  • 55
  • 464
  • 476
bitbucket
  • 1
  • 1

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
  • 53,704
  • 14
  • 91
  • 128
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,737
  • 14
  • 25