-1

I have a component that throws the following in the backend

memberSince: [ '["2022-05-05T08:13:07.551Z","2022-06-01T08:13:07.551Z"]' ]

Is there a way to un-stringify the array content like memberSince[0].parse() or something

Jam
  • 117
  • 11
  • 4
    `JSON.parse(memberSince[0])` – Anurag Srivastava May 19 '22 at 08:19
  • [Here's the documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse). (PS. It is the first entry when you search for [javascript parse](https://www.startpage.com/do/dsearch?query=javascript+parse).) – Andy May 19 '22 at 08:21

1 Answers1

0

You can use JSON.parse()

const data = {memberSince: ['["2022-05-05T08:13:07.551Z","2022-06-01T08:13:07.551Z"]']}

const result = JSON.parse(data.memberSince)

console.log(result)
Yosvel Quintero
  • 18,669
  • 5
  • 37
  • 46