I received an object from the backend and I need to extract its elements to attach them to the scope for viewing. The structure of the object is as follows:
{
"Name": {
"S": "Jon Snow"
},
"Location": {
"S": "Winterfell"
},
"Details": {
"M": {
"Parents": {
"M": {
"mother": {
"S": "Lynna Stark"
}
}
},
"Dog": {
"N": "Ghost Snow"
}
}
}
}
Since I'm unsure of the type of object received, my goal is to convert it into a plain JSON object like this:
{
"Name": "Jon Snow",
"Location": "Winterfell",
"Details": {
"Parents": {
"mother": "Lynna Stark"
},
"Dog": "Ghost Snow"
}
}
I would appreciate any help, especially since I am new to AngularJS. Can someone also explain the nature of the object I received? Thank you in advance.
Update 1: Thank you for the responses. I now understand the concept. My next question is how can I flatten the object by one level without altering the original backend response, which may vary each time?