-1

I am simply trying to parse through an array key=>value pair that has a .0 in it. Below is the JSON I'm trying to parse through.

{message: "The given data was invalid.", errors: {…}}
errors:
    step1.0: Array(1)
        0: "Invalid response."

I'm trying to get "Invalid response" to log in the console. I get caught up when I try

errors.step1.0[0]

...it doesn't like the ".0". I have tried to escape it with "\" and have tried using 0 in a string, but nothing is working. I'm sure it's a simple syntax issue.

Thank you!

Matt Pierce
  • 807
  • 3
  • 22
  • 45
  • 1
    That is not JSON you're showing. And "an array key=>value" is called an object, not an array. – VLAZ Oct 03 '18 at 04:18

1 Answers1

1

const obj = {
  "step1.0": 'test'
};

console.log(obj['step1.0']);

You can use bracket notation

Joven28
  • 769
  • 3
  • 12