I am in the process of figuring out how to take an object that is shaped like this:
{
"stores": {
store: [
{
location: {
city: "Austin,
state: "TX"
}
}
],
[ ... 100 more stores ]
}
}
What I need to do is create a new object where the store
would be the on the top level so that I can shape that as I need to rather than shaping the stores
.
{
"store": [
{
city: "Austin",
state: "TX"
},
{
city: "San Francisco",
state: "CA"
},
{ ... 100 more }
]
}
What would be the best way to have a new object created from the 1st object and be able to take the 2nd level and make it the first level? Do I have to create a new object or can I just manipulate the 1st?
How can this be done with the littlest amount of code needed without making it hard to maintain?
Why would the approach be used to shape the new object?
Thank you for any help in understanding the process of tackling this task
My final output needs to look similar to this:
{
company: "ABC",
companyId: 1234,
nasdaq: ABCND,
store: [], // this is where I will have all the objects stores in array
employees: 1000000
}
My hopes are that this will give more clarity to what I am trying to do with taking the first and shaping it to look like second.
Attention
After having discussions in the comments, this question should be closed because of the lack of clarity in the question and how it can be confusing. My hopes are that it is not closed, rather used as a reference for how not to ask a question on SO.