Good day,
I am currently working on creating a JSON file that organizes Portuguese parishes by district, municipality, and parish. The structure I am aiming for is as follows:
{
"district": "Aveiro",
"OfficialCodeDistrict": "01",
"municipalities": [
{
"municipality": "Arouca",
"OfficialCodeMunicipality": "0104",
"parishes": [
{
"parish": "Fermedo",
"OfficialCodeParish"
},
{
"parish": "Várzea",
"OfficialCodeParish": "010420"
},
{
"parish": "Escariz",
"OfficialCodeParish": "010409"
},
{
"parish": "Mansores",
"OfficialCodeParish": "010413"
}
]
},
{
"municipality": "Águeda",
"OfficialCodeMunicipality": "0101",
"parishes": [
{
"parish": "Fermentelos",
"OfficialCodeParish": "010109"
},
{
"parish": "Préstimo e Macieira de Alcoba",
"OfficialCodeParish": "010127"
}
]
}
]
}
Each district contains municipalities, and within each municipality, we list all the parishes. I utilized an existing JSON file obtained from an Excel export, which can be found here
Referring to a question on StackOverflow, I managed to group the municipalities within each district. However, I am currently struggling with grouping municipalities within their respective district, as illustrated in the linked image:
I attempted to manipulate the JSON structure by iterating through the municipalities within each district, but I am facing challenges in merging this information back into the original object. Any assistance on achieving the desired JSON structure would be greatly appreciated!
Thank you for your help in advance!