Answer the question
In order to leave comments, you need to log in
How to parse a multi-dimensional JS array and pull out the desired element from it?
Let's say we have an array like this:
[{"i_id":"2223", "i_post":"qwerty", "i_descriptions":[{"type":"html","value":"\r\n"},{"type":"html","value":" "},{"type":"html","value":"\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0442\u0438\u0440\u0430\u0436\u0430 #48","color":"99ccff"},{"type":"html","value":" "}], "ui_status":"4", "ui_bid":"12414124125"}]
Answer the question
In order to leave comments, you need to log in
function my_func(ui){
//Чего-то делаем, к примеру:
alert(ui);
}
var data = [
{"i_id":"2223", "i_post":"qwerty", "i_descriptions": [
{"type":"html","value":"\r\n"},
{"type":"html","value":" "},
{"type":"html","value":"\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0442\u0438\u0440\u0430\u0436\u0430 #48","color":"99ccff"},
{"type":"html","value":" "}
], "ui_status":"4", "ui_bid":"12414124125"},
{"i_id":"2228", "i_post":"qwerty", "i_descriptions": [
{"type":"html","value":"\r\n"},
{"type":"html","value":" "},
{"type":"html","value":"\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0442\u0438\u0440\u0430\u0436\u0430 #48","color":"99ccff"},
{"type":"html","value":" "}
], "ui_status":"4", "ui_bid":"0"}
];
data.forEach(function(e){
var ubid = e.ui_bid;
+ubid&&my_func(ubid);
});
var data = [{"i_id":"2223", "i_post":"qwerty", "i_descriptions":[{"type":"html","value":"\r\n"},{"type":"html","value":" "},{"type":"html","value":"\u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0442\u0438\u0440\u0430\u0436\u0430 #48","color":"99ccff"},{"type":"html","value":" "}], "ui_status":"4", "ui_bid":"12414124125"}];
for (var i in data) {
if (data[i].ui_bid != 0) {
// do something
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question