X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6e39d509471fe9b4e2660e0d1631b350d0c66f40..530ef4b6c5b943cfa68b779d11cf7de29aa878bf:/src/data/JsonReader.js diff --git a/src/data/JsonReader.js b/src/data/JsonReader.js index 03c3be99..d93f9f5d 100644 --- a/src/data/JsonReader.js +++ b/src/data/JsonReader.js @@ -1,6 +1,6 @@ /*! - * Ext JS Library 3.1.0 - * Copyright(c) 2006-2009 Ext JS, LLC + * Ext JS Library 3.2.1 + * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license */ @@ -165,13 +165,16 @@ Ext.extend(Ext.data.JsonReader, Ext.data.DataReader, { return this.readRecords(o); }, - /** - * Decode a json response from server. - * @param {String} action [Ext.data.Api.actions.create|read|update|destroy] - * @param {Object} response + /* * TODO: refactor code between JsonReader#readRecords, #readResponse into 1 method. * there's ugly duplication going on due to maintaining backwards compat. with 2.0. It's time to do this. */ + /** + * Decode a JSON response from server. + * @param {String} action [Ext.data.Api.actions.create|read|update|destroy] + * @param {Object} response The XHR object returned through an Ajax server request. + * @return {Response} A {@link Ext.data.Response Response} object containing the data response, and also status information. + */ readResponse : function(action, response) { var o = (response.responseText !== undefined) ? Ext.decode(response.responseText) : response; if(!o) { @@ -298,14 +301,20 @@ Ext.extend(Ext.data.JsonReader, Ext.data.DataReader, { createAccessor : function(){ var re = /[\[\.]/; return function(expr) { - try { - return(re.test(expr)) ? - new Function('obj', 'return obj.' + expr) : - function(obj){ - return obj[expr]; - }; - } catch(e){} - return Ext.emptyFn; + if(Ext.isEmpty(expr)){ + return Ext.emptyFn; + } + if(Ext.isFunction(expr)){ + return expr; + } + var i = String(expr).search(re); + if(i >= 0){ + return new Function('obj', 'return obj' + (i > 0 ? '.' : '') + expr); + } + return function(obj){ + return obj[expr]; + }; + }; }(),