JSON.stringify使用

来源:互联网 发布:网络维护和通信课程 编辑:程序博客网 时间:2024/05/19 19:14

这个方法用于把原来的对象转换为json的对象,

<!doctype html><html lang="en"><head>  <meta charset="utf-8">  <title>jQuery.extend demo</title>  <script src="https://code.jquery.com/jquery-1.10.2.js"></script></head><body><div id="log"></div><script>var object1 = {  apple: 0,  banana: { weight: 52, price: 100 },  cherry: 97};var object2 = {  banana: { price: 200 },  durian: 100};// Merge object2 into object1$.extend( object1, object2 );// Assuming JSON.stringify - not available in IE<8alert(object1);$( "#log" ).append( JSON.stringify( object1 ) );</script></body></html>
原创粉丝点击