"mainData"{
entities:[]
},
"data2":{
entities:[
{
name:"mainData": //entites
},
{
name:"mainData": //entites
},
{
name:"mainData": //entites
},
]
},
"data3":{
entites:[
{
name:"data2": //entites
},
{
name:"data2": //entites
},
{
name:"data2": //entites
},
{
name:"data2": //entites
},]
}
I am looking to modify the data structure by adding a count to each object related to mainData. For example, in data2.entities there are 3 instances of mainData, so the count should be 3. Similarly, in data3.entities there are 4 data2s and since each data2 has 3 mainData inside it, the total count for data3 should be 12.
edit: How is the count for data3 12?
It is because there are 4 data2s in data3's entities, and each data2 has 3 mainData entries, resulting in a total count of 12 based on the mainData count.
The desired output structure would look like this:
"mainData"{
entities:[]
},
"data2":{
count:3,
entities:[
{
name:"mainData": //entites
},
{
name:"mainData": //entites
},
{
name:"mainData": //entites
},
]
},
"data3":{
count:12,
entites:[
{
name:"data2": //entites
},
{
name:"data2": //entites
},
{
name:"data2": //entites
},
{
name:"data2": //entites
},]
}