无法在Typescript和Angular中正确发送json

时间:2018-06-23 22:06:32

标签: json typescript angular6

我想从Angular应用程序发送一个JSONjson的结构应为

{"data":{"field1":"d","field2":"d","field3":["d"],"field4":["d"],"field5":["d"],"field6":"d","field7":"d"}}

某些字段是字符串,而其他字段是数组

表示Angular的{​​{1}}类是

Data.class

json

Mydata.class

  constructor (public field1:string,
               public field2:string,
               public field3:Array<string>,
               public field4:string, 
               public field5:Array<string>,
               public field6:Array<any>,
               public field7:string){}

但是,正在发送的export class MyData{ constructor(public data:Data){ } json

发送的{"data":{"field1":"d","field2":"d","field3":"d","field4":"d","field5":"d","field6":"d","field7":"d"}}似乎只包含字符串,而不包含数组。如何发送json格式的json

0 个答案:

没有答案