-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,183
  • 15
  • 49
  • 67

1 Answers1

0

Example

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

enter image description here

Mridul
  • 1,205
  • 1
  • 4
  • 19