Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / docs / output / Ext.data.reader.Json.js
1 Ext.data.JsonP.Ext_data_reader_Json({
2   "allMixins": [
3
4   ],
5   "deprecated": null,
6   "docauthor": null,
7   "members": {
8     "cfg": [
9       {
10         "type": "String",
11         "deprecated": null,
12         "alias": null,
13         "protected": false,
14         "tagname": "cfg",
15         "href": "Reader.html#Ext-data-reader-Reader-cfg-idProperty",
16         "shortDoc": "Name of the property within a row object\nthat contains a record identifier value. ...",
17         "static": false,
18         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
19         "private": false,
20         "name": "idProperty",
21         "owner": "Ext.data.reader.Reader",
22         "doc": "<p>Name of the property within a row object\nthat contains a record identifier value.  Defaults to <tt>The id of the model</tt>.\nIf an idProperty is explicitly specified it will override that of the one specified\non the model</p>\n",
23         "linenr": 151,
24         "html_filename": "Reader.html"
25       },
26       {
27         "type": "Boolean",
28         "deprecated": null,
29         "alias": null,
30         "protected": false,
31         "tagname": "cfg",
32         "href": "Reader.html#Ext-data-reader-Reader-cfg-implicitIncludes",
33         "shortDoc": "True to automatically parse models nested within other models in a response\nobject. ...",
34         "static": false,
35         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
36         "private": false,
37         "name": "implicitIncludes",
38         "owner": "Ext.data.reader.Reader",
39         "doc": "<p>True to automatically parse models nested within other models in a response\nobject. See the <a href=\"#/api/Ext.data.reader.Reader\" rel=\"Ext.data.reader.Reader\" class=\"docClass\">Ext.data.reader.Reader</a> intro docs for full explanation. Defaults to true.</p>\n",
40         "linenr": 188,
41         "html_filename": "Reader.html"
42       },
43       {
44         "type": "String",
45         "deprecated": null,
46         "alias": null,
47         "protected": false,
48         "tagname": "cfg",
49         "href": "Reader.html#Ext-data-reader-Reader-cfg-messageProperty",
50         "shortDoc": "The name of the property which contains a response message. ...",
51         "static": false,
52         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
53         "private": false,
54         "name": "messageProperty",
55         "owner": "Ext.data.reader.Reader",
56         "doc": "<p>The name of the property which contains a response message.\nThis property is optional.</p>\n",
57         "linenr": 183,
58         "html_filename": "Reader.html"
59       },
60       {
61         "type": "String",
62         "deprecated": null,
63         "alias": null,
64         "protected": false,
65         "tagname": "cfg",
66         "href": "Json.html#Ext-data-reader-Json-cfg-record",
67         "shortDoc": "The optional location within the JSON response that the record data itself can be found at. ...",
68         "static": false,
69         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Json.js",
70         "private": false,
71         "name": "record",
72         "owner": "Ext.data.reader.Json",
73         "doc": "<p>The optional location within the JSON response that the record data itself can be found at.\nSee the JsonReader intro docs for more details. This is not often needed and defaults to undefined.</p>\n",
74         "linenr": 167,
75         "html_filename": "Json.html"
76       },
77       {
78         "type": "String",
79         "deprecated": null,
80         "alias": null,
81         "protected": false,
82         "tagname": "cfg",
83         "href": "Reader.html#Ext-data-reader-Reader-cfg-root",
84         "shortDoc": "Required. ...",
85         "static": false,
86         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
87         "private": false,
88         "name": "root",
89         "owner": "Ext.data.reader.Reader",
90         "doc": "<p><b>Required</b>.  The name of the property\nwhich contains the Array of row objects.  Defaults to <tt>undefined</tt>.\nAn exception will be thrown if the root property is undefined. The data\npacket value for this property should be an empty array to clear the data\nor show no data.</p>\n",
91         "linenr": 174,
92         "html_filename": "Reader.html"
93       },
94       {
95         "type": "String",
96         "deprecated": null,
97         "alias": null,
98         "protected": false,
99         "tagname": "cfg",
100         "href": "Reader.html#Ext-data-reader-Reader-cfg-successProperty",
101         "shortDoc": "Name of the property from which to\nretrieve the success attribute. ...",
102         "static": false,
103         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
104         "private": false,
105         "name": "successProperty",
106         "owner": "Ext.data.reader.Reader",
107         "doc": "<p>Name of the property from which to\nretrieve the success attribute. Defaults to <tt>success</tt>.  See\n<a href=\"#/api/Ext.data.proxy.Proxy\" rel=\"Ext.data.proxy.Proxy\" class=\"docClass\">Ext.data.proxy.Proxy</a>.exception\nfor additional information.</p>\n",
108         "linenr": 166,
109         "html_filename": "Reader.html"
110       },
111       {
112         "type": "String",
113         "deprecated": null,
114         "alias": null,
115         "protected": false,
116         "tagname": "cfg",
117         "href": "Reader.html#Ext-data-reader-Reader-cfg-totalProperty",
118         "shortDoc": "Name of the property from which to\nretrieve the total number of records in the dataset. ...",
119         "static": false,
120         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
121         "private": false,
122         "name": "totalProperty",
123         "owner": "Ext.data.reader.Reader",
124         "doc": "<p>Name of the property from which to\nretrieve the total number of records in the dataset. This is only needed\nif the whole dataset is not passed in one go, but is being paged from\nthe remote server.  Defaults to <tt>total</tt>.</p>\n",
125         "linenr": 158,
126         "html_filename": "Reader.html"
127       },
128       {
129         "type": "Boolean",
130         "deprecated": null,
131         "alias": null,
132         "protected": false,
133         "tagname": "cfg",
134         "href": "Json.html#Ext-data-reader-Json-cfg-useSimpleAccessors",
135         "shortDoc": "True to ensure that field names/mappings are treated as literals when\nreading values. ...",
136         "static": false,
137         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Json.js",
138         "private": false,
139         "name": "useSimpleAccessors",
140         "owner": "Ext.data.reader.Json",
141         "doc": "<p>True to ensure that field names/mappings are treated as literals when\nreading values. Defalts to <tt>false</tt>.\nFor example, by default, using the mapping \"foo.bar.baz\" will try and read a property foo from the root, then a property bar\nfrom foo, then a property baz from bar. Setting the simple accessors to true will read the property with the name\n\"foo.bar.baz\" direct from the root object.</p>\n",
142         "linenr": 172,
143         "html_filename": "Json.html"
144       }
145     ],
146     "method": [
147       {
148         "deprecated": null,
149         "alias": null,
150         "href": "Reader.html#Ext-data-reader-Reader-method-constructor",
151         "tagname": "method",
152         "protected": false,
153         "shortDoc": "Creates new Reader. ...",
154         "static": false,
155         "params": [
156           {
157             "type": "Object",
158             "optional": true,
159             "doc": "<p>(optional) Config object.</p>\n",
160             "name": "config"
161           }
162         ],
163         "private": false,
164         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
165         "doc": "<p>Creates new Reader.</p>\n",
166         "owner": "Ext.data.reader.Reader",
167         "name": "Json",
168         "html_filename": "Reader.html",
169         "return": {
170           "type": "Object",
171           "doc": "\n"
172         },
173         "linenr": 196
174       },
175       {
176         "deprecated": null,
177         "alias": null,
178         "protected": false,
179         "tagname": "method",
180         "href": "Reader.html#Ext-data-reader-Reader-method-getResponseData",
181         "shortDoc": "Takes a raw response object (as passed to this.read) and returns the useful data segment of it. ...",
182         "static": false,
183         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
184         "private": false,
185         "params": [
186           {
187             "type": "Object",
188             "optional": false,
189             "doc": "<p>The responce object</p>\n",
190             "name": "response"
191           }
192         ],
193         "name": "getResponseData",
194         "owner": "Ext.data.reader.Reader",
195         "doc": "<p>Takes a raw response object (as passed to this.read) and returns the useful data segment of it. This must be implemented by each subclass</p>\n",
196         "linenr": 460,
197         "return": {
198           "type": "Object",
199           "doc": "<p>The useful data from the response</p>\n"
200         },
201         "html_filename": "Reader.html"
202       },
203       {
204         "deprecated": null,
205         "alias": null,
206         "protected": false,
207         "tagname": "method",
208         "href": "Reader.html#Ext-data-reader-Reader-method-read",
209         "shortDoc": "Reads the given response object. ...",
210         "static": false,
211         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
212         "private": false,
213         "params": [
214           {
215             "type": "Object",
216             "optional": false,
217             "doc": "<p>The response object. This may be either an XMLHttpRequest object or a plain JS object</p>\n",
218             "name": "response"
219           }
220         ],
221         "name": "read",
222         "owner": "Ext.data.reader.Reader",
223         "doc": "<p>Reads the given response object. This method normalizes the different types of response object that may be passed\nto it, before handing off the reading of records to the <a href=\"#/api/Ext.data.reader.Json-method-readRecords\" rel=\"Ext.data.reader.Json-method-readRecords\" class=\"docClass\">readRecords</a> function.</p>\n",
224         "linenr": 228,
225         "return": {
226           "type": "Ext.data.ResultSet",
227           "doc": "<p>The parsed ResultSet object</p>\n"
228         },
229         "html_filename": "Reader.html"
230       },
231       {
232         "deprecated": null,
233         "alias": null,
234         "protected": false,
235         "tagname": "method",
236         "href": "Json.html#Ext-data-reader-Json-method-readRecords",
237         "shortDoc": "Reads a JSON object and returns a ResultSet. ...",
238         "static": false,
239         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Json.js",
240         "private": false,
241         "params": [
242           {
243             "type": "Object",
244             "optional": false,
245             "doc": "<p>The raw JSON data</p>\n",
246             "name": "data"
247           }
248         ],
249         "name": "readRecords",
250         "owner": "Ext.data.reader.Json",
251         "doc": "<p>Reads a JSON object and returns a ResultSet. Uses the internal getTotal and getSuccess extractors to\nretrieve meta data from the response, and extractData to turn the JSON data into model instances.</p>\n",
252         "linenr": 181,
253         "return": {
254           "type": "Ext.data.ResultSet",
255           "doc": "<p>A ResultSet containing model instances and meta data about the results</p>\n"
256         },
257         "html_filename": "Json.html"
258       }
259     ],
260     "property": [
261       {
262         "type": "Mixed",
263         "deprecated": null,
264         "alias": null,
265         "protected": false,
266         "tagname": "property",
267         "href": "Json.html#Ext-data-reader-Json-property-jsonData",
268         "shortDoc": "DEPRECATED - will be removed in Ext JS 5.0. ...",
269         "static": false,
270         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Json.js",
271         "private": false,
272         "name": "jsonData",
273         "owner": "Ext.data.reader.Json",
274         "doc": "<p>DEPRECATED - will be removed in <a href=\"#/api/Ext\" rel=\"Ext\" class=\"docClass\">Ext</a> JS 5.0. This is just a copy of this.rawData - use that instead</p>\n",
275         "linenr": 193,
276         "html_filename": "Json.html"
277       },
278       {
279         "type": "Mixed",
280         "deprecated": null,
281         "alias": null,
282         "protected": false,
283         "tagname": "property",
284         "href": "Reader.html#Ext-data-reader-Reader-property-rawData",
285         "shortDoc": "The raw data object that was last passed to readRecords. ...",
286         "static": false,
287         "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Reader.js",
288         "private": false,
289         "name": "rawData",
290         "owner": "Ext.data.reader.Reader",
291         "doc": "<p>The raw data object that was last passed to readRecords. Stored for further processing if needed</p>\n",
292         "linenr": 268,
293         "html_filename": "Reader.html"
294       }
295     ],
296     "cssVar": [
297
298     ],
299     "cssMixin": [
300
301     ],
302     "event": [
303
304     ]
305   },
306   "singleton": false,
307   "alias": null,
308   "superclasses": [
309     "Ext.data.reader.Reader"
310   ],
311   "protected": false,
312   "tagname": "class",
313   "mixins": [
314
315   ],
316   "href": "Json.html#Ext-data-reader-Json",
317   "subclasses": [
318     "Ext.data.reader.Array"
319   ],
320   "static": false,
321   "author": "Ed Spencer",
322   "component": false,
323   "filename": "/mnt/ebs/nightly/git/SDK/platform/src/data/reader/Json.js",
324   "private": false,
325   "alternateClassNames": [
326     "Ext.data.JsonReader"
327   ],
328   "name": "Ext.data.reader.Json",
329   "doc": "<p>The JSON Reader is used by a Proxy to read a server response that is sent back in JSON format. This usually\nhappens as a result of loading a Store - for example we might create something like this:</p>\n\n\n\n\n<pre><code>Ext.define('User', {\n    extend: 'Ext.data.Model',\n    fields: ['id', 'name', 'email']\n});\n\nvar store = new Ext.data.Store({\n    model: 'User',\n    proxy: {\n        type: 'ajax',\n        url : 'users.json',\n        reader: {\n            type: 'json'\n        }\n    }\n});\n</code></pre>\n\n\n\n\n<p>The example above creates a 'User' model. Models are explained in the <a href=\"#/api/Ext.data.Model\" rel=\"Ext.data.Model\" class=\"docClass\">Model</a> docs if you're\nnot already familiar with them.</p>\n\n\n\n\n<p>We created the simplest type of JSON Reader possible by simply telling our <a href=\"#/api/Ext.data.Store\" rel=\"Ext.data.Store\" class=\"docClass\">Store</a>'s \n<a href=\"#/api/Ext.data.proxy.Proxy\" rel=\"Ext.data.proxy.Proxy\" class=\"docClass\">Proxy</a> that we want a JSON Reader. The Store automatically passes the configured model to the\nStore, so it is as if we passed this instead:\n\n<pre><code>reader: {\n    type : 'json',\n    model: 'User'\n}\n</code></pre>\n\n<p>The reader we set up is ready to read data from our server - at the moment it will accept a response like this:</p>\n\n<pre><code>[\n    {\n        \"id\": 1,\n        \"name\": \"Ed Spencer\",\n        \"email\": \"ed@sencha.com\"\n    },\n    {\n        \"id\": 2,\n        \"name\": \"Abe Elias\",\n        \"email\": \"abe@sencha.com\"\n    }\n]\n</code></pre>\n\n<p><u>Reading other JSON formats</u></p>\n\n<p>If you already have your JSON format defined and it doesn't look quite like what we have above, you can usually\npass JsonReader a couple of configuration options to make it parse your format. For example, we can use the \n<a href=\"#/api/Ext.data.reader.Json-cfg-root\" rel=\"Ext.data.reader.Json-cfg-root\" class=\"docClass\">root</a> configuration to parse data that comes back like this:</p>\n\n<pre><code>{\n    \"users\": [\n       {\n           \"id\": 1,\n           \"name\": \"Ed Spencer\",\n           \"email\": \"ed@sencha.com\"\n       },\n       {\n           \"id\": 2,\n           \"name\": \"Abe Elias\",\n           \"email\": \"abe@sencha.com\"\n       }\n    ]\n}\n</code></pre>\n\n<p>To parse this we just pass in a <a href=\"#/api/Ext.data.reader.Json-cfg-root\" rel=\"Ext.data.reader.Json-cfg-root\" class=\"docClass\">root</a> configuration that matches the 'users' above:</p>\n\n<pre><code>reader: {\n    type: 'json',\n    root: 'users'\n}\n</code></pre>\n\n<p>Sometimes the JSON structure is even more complicated. Document databases like CouchDB often provide metadata\naround each record inside a nested structure like this:</p>\n\n<pre><code>{\n    \"total\": 122,\n    \"offset\": 0,\n    \"users\": [\n        {\n            \"id\": \"ed-spencer-1\",\n            \"value\": 1,\n            \"user\": {\n                \"id\": 1,\n                \"name\": \"Ed Spencer\",\n                \"email\": \"ed@sencha.com\"\n            }\n        }\n    ]\n}\n</code></pre>\n\n<p>In the case above the record data is nested an additional level inside the \"users\" array as each \"user\" item has\nadditional metadata surrounding it ('id' and 'value' in this case). To parse data out of each \"user\" item in the \nJSON above we need to specify the <a href=\"#/api/Ext.data.reader.Json-cfg-record\" rel=\"Ext.data.reader.Json-cfg-record\" class=\"docClass\">record</a> configuration like this:</p>\n\n<pre><code>reader: {\n    type  : 'json',\n    root  : 'users',\n    record: 'user'\n}\n</code></pre>\n\n<p><u>Response metadata</u></p>\n\n<p>The server can return additional data in its response, such as the <a href=\"#/api/Ext.data.reader.Json-cfg-totalProperty\" rel=\"Ext.data.reader.Json-cfg-totalProperty\" class=\"docClass\">total number of records</a> \nand the <a href=\"#/api/Ext.data.reader.Json-cfg-successProperty\" rel=\"Ext.data.reader.Json-cfg-successProperty\" class=\"docClass\">success status of the response</a>. These are typically included in the JSON response\nlike this:</p>\n\n<pre><code>{\n    \"total\": 100,\n    \"success\": true,\n    \"users\": [\n        {\n            \"id\": 1,\n            \"name\": \"Ed Spencer\",\n            \"email\": \"ed@sencha.com\"\n        }\n    ]\n}\n</code></pre>\n\n<p>If these properties are present in the JSON response they can be parsed out by the JsonReader and used by the\nStore that loaded it. We can set up the names of these properties by specifying a final pair of configuration \noptions:</p>\n\n<pre><code>reader: {\n    type : 'json',\n    root : 'users',\n    totalProperty  : 'total',\n    successProperty: 'success'\n}\n</code></pre>\n\n<p>These final options are not necessary to make the Reader work, but can be useful when the server needs to report\nan error or if it needs to indicate that there is a lot of data available of which only a subset is currently being\nreturned.</p>\n\n",
330   "mixedInto": [
331
332   ],
333   "linenr": 1,
334   "xtypes": [
335
336   ],
337   "html_filename": "Json.html",
338   "extends": "Ext.data.reader.Reader"
339 });