(1)JSON.parse 函数
var json = '{"name":"GDT","age":23,"University":"GDUT"}'; var info = JSON.parse(json); //解析为JSON对象 document.write(info.name + ' is a student of ' + info.University + ' and he is ' + info.age + " years old."); /info为Object对象
(2)JSON.stringify()函数
var info = {name:"GDT",age:23,University:"GDUT"}; var json = JSON.stringify(info); //转换为JSON字符串 document.write(json); //output为{"name":"GDT","age":23,"University":"GDUT"}
(3)eval()函数
var json = '{"name":"GDT","age":23,"University":"GDUT"}'; var info = eval('(' + json + ')'); //解析为JSON对象 document.write(info); //output为[object Object]