I am facing an issue in small requirement. I want to create a JSON array in below format using JavaScript for loops.
var mainJson = {
"people": [{
"name": "Ravi",
"role": "team member",
"appointments": [{
"info": "room 1",
"type": "Type01"
"title": "Meet John Miller"
}, {
"info": "room 2",
"type": "Type02"
"title": "Meet Mitchell"
}]
]
}
};
To create above JSON, I have 2 jsons like below..
var subJson1 = [{
"RowId": "00272727",
"Rowlabel": "Ravi",
"role": "team member"
}]
var subJson2 = [{
"info": "room 1",
"RowId": "00272727",
"type": "Type01",
"title": "Meet John Miller"
}, {
"info": "room 2",
"type": "Type02",
"RowId": "00272727",
"title": "Meet Mitchell"
}]
Here in both SubJson1 and subJson2 "RowID" is the common parameter. Based on RowId we have to create mainJson .In the mainJson in people array objects will be more than 1. im just displaying only one item for understanding.
Im trying to achieve this with for loops. But im facing issues to resolve this. Can some one help me to create the mainJson using subJson1 and subJson2
Thank you in advance.