Closed ABHINAV112 closed 3 years ago
Try initializing the "TimeData" inside the for loop.
Since you assigned "TimeData" outside the for loop in line 23, when you are assigning megaTimeData[i] to TimeData in line 27, it essentially references megaTimeData[i] to the same memory location as "TimeData". That is the reason your changes are reflected everywhere in your JSON file
I did that but now i changed up the structure of the inner JSON object, and now it's not working. I am now getting an error which says assigning a property to an undefined object.
You have used i in both the inner and outer for loops. I think that is what is causing the problem. Try changing inner for loop variable to j.
Oh ok made the changes and adjusted some code it's working now.
Thanks
Your issue/question: After assigning JSON objects to a JSON the same change is made to every inner JSON instead of only the required JSON which should be changed.
What you expect to achieve Each assignment should only be made to the required JSON object and not every inner JSON object.
What happens instead Every inner JSON object is updated at the same time when only one of them should get updated.
Screenshots
Your system/software details Running an Ubuntu 18.04 LTS