Reputation: 362
DB JSON column data: ["admin", "leader", "manager"]
javascript recieves: ["admin", "leader", "manager"]
What is the simplest way to create Javascript array?
Upvotes: 2
Views: 427
Reputation: 3032
Just replace "" ;" to quotes and parse
const s = "["admin", "leader", "manager"]"
const obj = JSON.parse(s.replace(/"/g, "\"")))
but better check why do you receive data in such format
Upvotes: 2