У меня есть массив и много объектов в нем. Я хочу иметь возможность запускать каждую функцию для изменения каждого files/a
с files/and
в каждом subpage > file
узлах. Как я могу сделать это с правильной функцией каждого или цикла? Я думаю об этом, и это структура ниже в моем сознании и выглядит ужасным решением.
$.each(main, function( index, value ) {
$.each(index.subpage, function( index, value ) {
$.each(index.files, function( index, value ) {
value.replace("files/a", "files/and");
});
});
});
Основной объект выглядит так, как показано ниже.
{
"main": [
{
"title": "AAA",
"hash": "a",
"subpage": [
{
"title": "b",
"hash": "b",
"subpage": [
{
"title": "c",
"hash": "c",
"subpage": [],
"files": [
{
"files/a/b/c/01_clandestino_dev%20%282%29.jpg": {}
},
{
"files/a/b/c/01_clandestino_dev%20%283%29.jpg": {}
}
],
"content": "",
"layout": "standart"
}
],
"files": [
{
"files/a/b/01_clandestino_dev%20%282%29.jpg": {}
},
{
"files/a/b/01_clandestino_dev%20%283%29.jpg": {}
}
],
"content": "asd123",
"layout": "standart"
}
],
"files": [
{
"files/a/01_clandestino_dev.jpg": {}
},
{
"files/a/01.Creative_Collective_Effect_Overview.jpg": {}
},
{
"files/a/01.Bor%C3%A5s_H%C3%B6gskola_Website_Narrow.jpg": {}
}
],
"content": "AAAb",
"layout": "standart",
"menuItem": "true"
}
]
}