如何使用角度为5的JSON文件动态构建模型类

时间:2018-04-24 13:55:15

标签: typescript angular5

通过读取json文件,将所有名称存储在一个数组中,并将类型存储在typescript类中的一个数组中,但如何动态构建模型类

这是JSON

     "layoutItems": [ {

                                "type": "string",
                                "name": "firstname",
                                "label": "Name",
                                },
                            {
                                  "type": "string",
                                "name": "middlename",
                                "label": "Middle Name",
                                 },
                            {

                                "type": "number",
                                "name": "age",
                                "label": "Age",
                             },
                            {
                                "type": "number",
                                "name": "mobile",
                                "label": "Mobile",
                               },
    }]

need to build model export class like


  export class User{
        firstname: string;
        middlename: string;
        age: number;
        mobile: number;
    }

0 个答案:

没有答案