I have an array and many objects in it. I want to be able to run an each function to change every files/a
with files/and
in every subpage > file
nodes. How can i do this with a proper each or loop function? I think about that and it is the structure below in my mind and looks like terrible solution.
$.each(main, function( index, value ) {
$.each(index.subpage, function( index, value ) {
$.each(index.files, function( index, value ) {
value.replace("files/a", "files/and");
});
});
});
The main object looks like below.
{
"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"
}
]
}