Answer the question
In order to leave comments, you need to log in
How to pass name and from JSON to JS object?
Help kindly. I have this situation, there is a JSON file with content
[
{ "name": "foo",
"status": "success" }, {
"name": "bar",
"status": "success"}, {
"name": "biz",
"status": "success"
}
]
Answer the question
In order to leave comments, you need to log in
I don’t know what kind of object it is, but it’s easy into an array.
let str = `[
{ "name": "foo",
"status": "success" }, {
"name": "bar",
"status": "success"}, {
"name": "biz",
"status": "success"
}
]`;
let obj = JSON.parse(str);
let list = obj.map(x => x.name);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question