我将如何从json文件创建一个模型? (ExtJS的) [英] How I'll create a model from json file? (ExtJS)

查看:112
本文介绍了我将如何从json文件创建一个模型? (ExtJS的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个我想使用json文件创建的模型

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'}]
});

为了自动创建这个模型,我需要做什么,根据json的内容

What do I have to do in order to automatically create this model, based on the content of a json response from the server?

推荐答案

为了自动创建模型,您需要包含元数据字段与您的Json数据。 metaData 可用于描述模型的所有字段。

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.

在ExtJS 4.1文档中 - Ext.data.reader.Json 有一个名为Response MetaData的部分,描述了此功能的基本用法。

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

这篇关于我将如何从json文件创建一个模型? (ExtJS的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆