示例:
var thing = {plugin: 'jquery-json', version: 2.3};
var encoded = $.toJSON( thing );
// '{"plugin":"jquery-json","version":2.3}'
var name = $.evalJSON( encoded ).plugin;
// "jquery-json"
var version = $.evalJSON(encoded).version;
// 2.3
=================================================
Most people asked me why I would want to do such a thing, which boggles my mind. JavaScript makes it relatively easy to convert from JSON, thanks to eval(), but converting to JSON is supposedly an edge requirement.
This plugin exposes four new functions onto the $, or jQuery object:
google code :
jquery.json-2.3.min.js (2.13 KB) 031