Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Cameron Bourke
10,198 PointsJSON & LocalStorage
Hey guys.
Just wondering if anyone knows whether LocalStorage can store JSON data. I've got data that has nested objects but when I parse it out using JSON.parse(data) it does not include the nested objects.
Any help would be greatly appreciated!
Cheers.
1 Answer
Sean Ahern
7,533 PointsHey Cameron,
Do any of the missing objects contain functions declarations, or undefined placeholder properties? JSON.stringify() will drop any child properties that are set to undefined or a function declartion.
Cameron Bourke
10,198 PointsCameron Bourke
10,198 PointsIt turns out that my promise had not resolved quick enough so the child object never stored into localstorage. Thanks for the help anyways Sean Ahern.