最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Javascript - Saving 2d Array to Local Storage and retrieving - Stack Overflow

programmeradmin3浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 8

Use 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);
发布评论

评论列表(0)

  1. 暂无评论