Parsing Json

When I use the ‘GET’ method during an API call, and get my json back (during the .then(function(json) { … });

How do I then save the json file locally? I know that Storage.write(jsonfilename, json);

Do I do a JSON.stringify(json). and save that in the above storage.write? Or does it need to be JSON.parse(json) and save it in that spot?

Does my question make sense? Thanks in advance!

Hi Caleb,

when you parse a JSON string, it becomes an object (or an array, if it was one). So when you want to save that object/array, you should obviously convert it to a string representation, using stringify. Then, when you again read it from storage, you’ll parse it just as you did when reading from the remote API.