读书人

ext src 札记 json string数据转换

发布时间: 2012-11-23 00:03:43 作者: rapoo

ext src 笔记 json string数据转换

Ext.extend(Ext.data.JsonReader, Ext.data.DataReader, {    /**     * This JsonReader's metadata as passed to the constructor, or as passed in     * the last data packet's <b><tt>metaData</tt></b> property.     * @type Mixed     * @property meta     */    /**     * This method is only used by a DataProxy which has retrieved data from a remote server.     * @param {Object} response The XHR object which contains the JSON data in its responseText.     * @return {Object} data A data block which is used by an Ext.data.Store object as     * a cache of Ext.data.Records.     */    read : function(response){        var json = response.responseText;        var o = Ext.decode(json);        if(!o) {            throw {message: "JsonReader.read: Json object not found"};        }        return this.readRecords(o);    }

?

?

Ext.util.JSON = new (function(){    var useHasOwn = !!{}.hasOwnProperty,        isNative = function() {            var useNative = null;            return function() {                if (useNative === null) {                    useNative = Ext.USE_NATIVE_JSON && window.JSON && JSON.toString() == '[object JSON]';                }                        return useNative;            };        }(),        pad = function(n) {            return n < 10 ? "0" + n : n;        },        doDecode = function(json){            return eval("(" + json + ')');            }

?

?

读书人网 >JavaScript

热点推荐