Check out this object sample, I want to iterate through and dynamically assign {"type": "object"} within each inner object.
Input:
var favoriteFruit = { "Amy": { "desc": "Amy's fav", "fruit": { "Name" : "Banana", "color" : "Red" } }, "Ben": { "desc": "Ben's fav", "fruit": { "Name" : "Apple", "color" : "Red" } }, "Carol": { "desc": "Carol's fav", "fruit": { "Name" : "Cherry", "color" : "Red" } }, "Olivia": { "desc": "Olivia fav", "fruit": { "Name" : "Orange", "color" : "Orange" } }, "Pualine": { "desc": "Pualine fav", "fruit": { "Name" : "Pear", "color" : "Green" } } };
Expected output:
var favoriteFruit = {
"Amy": {
"type": "object",
"desc": "Amy's fav",
"fruit": {
"Name" : "Banana",
"color" : "Red"
}
},
"Ben": {
"type": "object",
"desc": "Ben's fav",
"fruit": {
"Name" : "Apple",
"color" : "Red"
}
},
"Carol": {
"type": "object",
"desc": "Carol's fav",
"fruit": {
"Name" : "Cherry",
"color" : "Red"
}
},
"Olivia": {
"type": "object",
"desc": "Olivia fav",
"fruit": {
"Name" : "Orange",
"color" : "Orange"
}
},
"Pualine": {
"type": "object",
"desc": "Pualine fav",
"fruit": {
"Name" : "Pear",
"color" : "Green"
}
}
};