2014-10-17 42 views
0

的帮助下,我在我的本地存储文件 10/10/2014 19:23:34(日期和时间)作为重点1项,阵列检索用的localStorage

{"entries":[{"name":"s","contact":"s","location":"s","email":"[email protected]","detail":"s","f_name":"form1"}]} 

(表单字段记录)作为价值

所以我的问题是如何得到这个阵列分离参数,如Name = sContact = s,等...

回答

0

如果您尚未分析你的数据,你可以分析它是这样的:

var json = localStorage.getItem('10/10/2014 19:23:34'); 

if (json) { 
    var data = JSON.parse(json); 

    if (data !== null) { 
     // then you can try to do something with the data within it 
     var entries = data.entries; 

     for (var i = 0, l = entries.length; i < l; i++) { 
      var entry = entries[i]; 
      console.log(entry.name, entry.contact, entry.location, entry.email); 
     } 
    } 
}