Answer the question
In order to leave comments, you need to log in
How to convert json array?
Please tell me how the array of the form
[{"id":"99","parent_id":"105},{"id":"13","parent_id":"305"}]
[99, 13]
Answer the question
In order to leave comments, you need to log in
var a = [{"id":"99","parent_id":"105"},{"id":"13","parent_id":"305"}].map(
function (item) {
return +item.id;
}
);
need more crutches
function getValuesByKey(array, key) {
const res = array.map((item) => {
return +item[key] || 0;
});
return res || [];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question