I have a two-dimensional array holding information which I need to save to local storage and then retrieve later. Here is my data:
var content_array = [
["0","Mobile Application Development","CT5006","01/14/2013","Note"],
["1","Java Programming","CT5005","01/16/2013","Note"],
["2","Multimeida Application Development","CT5011","02/13/2013","Note"]
];
Any easy way to turn this into a string then back into a 2D array?
I have a two-dimensional array holding information which I need to save to local storage and then retrieve later. Here is my data:
var content_array = [
["0","Mobile Application Development","CT5006","01/14/2013","Note"],
["1","Java Programming","CT5005","01/16/2013","Note"],
["2","Multimeida Application Development","CT5011","02/13/2013","Note"]
];
Any easy way to turn this into a string then back into a 2D array?
Share Improve this question edited Aug 22, 2018 at 6:30 James W. asked Jan 8, 2013 at 16:30 James W.James W. 1843 silver badges13 bronze badges1 Answer
Reset to default 8Use the native JSON.stringify
method:
var str = JSON.stringify(content_array);
You can then use the JSON.parse
method to get it back into an actual array:
var content_array = JSON.parse(str);