<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title></title> </head> <body> <p>方法:闯入json字符串</p> var json= FastJson.format(jsonString) <br> <p>方法:闯入json对象</p> var json= FastJson.format(jsonObject) <br> <div id="test"> <h3>测试</h3> <pre> { books:[ { id:1, name:‘name 1‘ sort:{ id:1, name:‘儿童教育‘ } }, { id:2, name:‘name 2‘, sort:{ ‘$ref‘:‘$.books[0].sort‘ } } ] } </pre> </div> <script type="text/javascript" src="FastJson-1.0.min.js"></script> <script> var data = { books: [{ id: 1, name: ‘name 1‘, sort: { id: 1, name: ‘儿童教育‘ } }, { id: 2, name: ‘name 2‘, sort: { ‘$ref‘: ‘$.books[0].sort‘ } }] }; alert("befor data.books[1].sort.name:"+data.books[1].sort.name); FastJson.format(data); alert("alter data.books[1].sort.name:"+data.books[1].sort.name); </script> </body> </html>
FastJson下载地址
http://code.taobao.org/p/fastjson-js/src/FastJson-1.0.min.js
时间: 2024-10-10 04:30:04