I am looking for a solution to load the nested json in the parent model to be eventually rendered on screen. I have a nested json in this format:
{
"name":"Hotel-A",
"description":"5 star rating",
"geographicAddress":{
"streetAddress":"343,Market st",
"city":"San Jose",
"state":"CA",
"country":"USA",
"postalCode":"34523"
},
"id":"338a947b-c488-46a9-b68f-640fcda38577"
}
I have a parent model which further has reference to geographicAddress and geographicPoint model.
This is how it looks:
Parent model:
defaults:{
"id" : "",
"name" : "",
"description" : "",
"geographicAddress": new geoAddress(),
}
Parent Collection:
addParentModel: function(parent) {
var newParentModel = new this.model();
newParentModel.set({
id: parent.id,
name: parent.name,
description: parent.description,
address:geoAddress.streetAddress,
city:geoAddress.city,
state:geoAddress.state,
postalCode:geoAddress.postalCode
});
geographic Address Model:
defaults:{
"streetAddress":"",
"city":"",
"state":"",
"country":"",
"postalCode":""
}
Could someone show me a way to populate the parent model with the nested json and render it in html.
Thank you.