-<html>\r
-<head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \r
- <title>The source code</title>\r
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body onload="prettyPrint();">\r
- <pre class="prettyprint lang-js"><div id="cls-Ext.data.JsonReader"></div>/**
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>The source code</title>
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body onload="prettyPrint();">
+ <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.3.1
+ * Copyright(c) 2006-2010 Sencha Inc.
+ * licensing@sencha.com
+ * http://www.sencha.com/license
+ */
+<div id="cls-Ext.data.JsonReader"></div>/**
* @class Ext.data.JsonReader
* @extends Ext.data.DataReader
* <p>Data reader class to create an Array of {@link Ext.data.Record} objects
// constructor that provides mapping for reading the record data objects
{@link Ext.data.DataReader#fields fields}: [
// map Record's 'firstname' field to data object's key of same name
- {name: 'name'},
+ {name: 'name', mapping: 'firstname'},
// map Record's 'job' field to data object's 'occupation' key
{name: 'job', mapping: 'occupation'}
]
return this.readRecords(o);
},
- <div id="method-Ext.data.JsonReader-readResponse"></div>/**
- * 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.
*/
+ <div id="method-Ext.data.JsonReader-readResponse"></div>/**
+ * 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) {
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];
+ };
+
};
}(),
'root-empty': 'Data was expected to be returned by the server in the "root" property of the response. Please review your JsonReader configuration to ensure the "root" property matches that returned in the server-response. See JsonReader docs.'
}
});
-</pre> \r
-</body>\r
+</pre>
+</body>
</html>
\ No newline at end of file