How I'll create a model from json file? (ExtJS)

extjs, extjs4.1, javascript

Solution

In order to have the model created automatically, you need to include the `metaData` field with your Json data. `metaData` can be used to describe all of the fields for the Model.

In the ExtJS 4.1 documentation - Ext.data.reader.Json has a section called Response MetaData which describes basic use of this feature.

Problem

This the model that I want to create using json file ``` Ext.define('Users', { extend: 'Ext.data.Model', fields: [{name: 'user_id', type: 'int'}, {name: 'user_name', type: 'string'}] }); ``` What do I have to do in order to automatically create this model, based on the content of a json response from the server?

Original source