JSON.parse与JSON.stringify

来源:互联网 发布:吉利知豆d2多少钱 编辑:程序博客网 时间:2024/06/01 09:00


var jsontext = '{"firstname":"Jesper","surname":"Aaberg","phone":["555-0100","555-0120"]}'; 
var contact = JSON.parse(jsontext); 
document.write(contact.surname + ", " + contact.firstname); 
document.write(contact.phone[1]); 


document.write ("<br/>"); 
document.write ("<br/>"); 
document.write ("<br/>"); 
var arr = {"firstname":"Jesper","surname":"Aaberg","phone":["555-0100","555-0120"]}; 
var str = JSON.stringify(arr); 
document.write(str); 
0 0
原创粉丝点击