DEV Community

Discussion on: A cheat sheet for working with JSON Data in JavaScript

james_palermo_bc208e463e4 profile image
James Palermo

I think I found a solution. You can do this in a function:
localStorage.setItem('NameOfThing', JSON.stringify(yourJSON);

then in another function/scope you can call that so:
let VarNameForThing = JSON.parse(localStorage.getItem('NameOfThing');

that moves the object to wherever you need it. I don't know if its a bad idea for some reason but it seems to work for basic stuff at least.