重要提示:2.0不向后兼容以前的版本
这个插件可以很方便的对json操作,
var thing = { plugin: ‘jquery-json‘, version: 2.4 }; var encoded = $.toJSON( thing ); // ‘{"plugin":"jquery-json","version":2.4}‘ var name = $.evalJSON( encoded ).plugin; // "jquery-json" var version = $.evalJSON(encoded).version; // 2.4
- toJSON: 序列化的JavaScript对象,数字,字符串或数组转换为JSON对象
- evalJSON: 转换从JSON为Javascript对象(json转字符串)
- secureEvalJSON: Converts from JSON to Javascript, but does so while checking to see if the source is actually JSON, and not with other Javascript statements thrown in.
- quoteString: Places quotes around a string, and intelligently escapes any quote, backslash, or control characters.
- quoteString:放置引号的字符串,并智能地转义任何引号,反斜线,或控制字符。
- secureEvalJSON:转换从JSON为Javascript,但这样做同时检查,看看源实际上是JSON,而不是与其他的JavaScript语句抛出英寸