Really confused here. On my current project all data is stored in localStorage, and all objects/arrays have maximum one level of nesting. That results in many inconveniences and even duplicates of the same entities. I decided to refactor the data structure to something more convenient, but also more nested.
Would it be safe and reliable to JSON.stringify()
/ JSON.parse()
back and forth such data? Some of google search results states that json does not support nested arrays, but it does support them! Or..?
what I have now:
cars: [{id: car1, brand: 'bmw'}, {id: car2, brand: 'ford'}, {id: car3, brand: 'dodge'}]
car1_details: {id: car1, color: 'blue', horsepower: 150, type: 'coupe']
car2_details: {id: car2, color: 'red', horsepower: 180, type: 'hatchback']
car3_details: {id: car3, color: 'yellow', horsepower: 200, type: 'sedan']
what I obviously want:
cars: [
{
id: car1,
brand: 'bmw',
details: {
color: 'blue',
horsepower: 150,
type: 'coupe'
}
//etc
]
I tested and it seems to be 100% working, but just wanted to make sure by asking you guys. Also there is this outdated post, but apparently it has been fixed since then.