Answer the question
In order to leave comments, you need to log in
How to parse a string as an array inside json?
const req = {array: '[{num: 1}, {num: 2}, {num: 3}]'};
console.log(req.array) //Выводит как строку, а нужно вывести как массив.
console.log(JSON.parse(req.array)) // Не работает
Answer the question
In order to leave comments, you need to log in
console.log(JSON.parse(req.array)) // Не работает
Of course, it just takes it and "does not work" - it probably has a day off ...
This code should give an error. Have you tried reading the error?
'[{num: 1}, {num: 2}, {num: 3}]'
'[{"num": 1}, {"num": 2}, {"num": 3}]'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question