-1

I have the following JSON string and for example I need to access a single element of the array. Let's say I just wanted to pull out "host2." I keep trying things like members[1] but that doesn't work. I keep getting "undefined."

{
  "members": [
    "host1",
    "host2",
    "host3"
  ]
}
Jimmy D
  • 5,282
  • 16
  • 54
  • 70

1 Answers1

0

Example

 let d = {
  "members": [
    "host1",
    "host2",
    "host3"
  ]
};
console.log(d);
console.log(d.members[1]);

enter image description here

Mridul
  • 1,320
  • 1
  • 5
  • 19