Friday 2 June 2017

How can I create an array of objects duplicated from a required JSON file?

I am trying to create an array of objects where I use a template JSON object from a required .json file, edit one field, create a new object and push that object to an array for later use. The problem I'm running into is that I am editing the base object and every time it gets pushed into the array, every preceding object is updated as well. I know it's because the object is simply a reference to the base object, I just don't know how to counter it.



via Jordeaux

No comments:

Post a Comment