如何将JSON对象转换为TypeScript类? [英] How do I cast a JSON Object to a TypeScript class?
本文介绍了如何将JSON对象转换为TypeScript类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从远程REST服务器读取了JSON对象.此JSON对象具有Typescript类的所有属性(通过设计).如何将收到的JSON对象转换为var类型?
I read a JSON object from a remote REST server. This JSON object has all the properties of a typescript class (by design). How do I cast that received JSON object to a type var?
我不想填充typescript变量(即,具有使用此JSON对象的构造函数).它很大,可以逐个对象地复制所有内容.逐个财产会花费很多时间.
I don't want to populate a typescript var (ie have a constructor that takes this JSON object). It's large and copying everything across sub-object by sub-object & property by property would take a lot of time.
查看全文