this.getdata() 为我提供以下格式的数据。
{
"MyRequest":{
"Month":"",
"Number":"003254810"
}
}
我有另一个请求,我想将上面的 json 属性传递给 Myrequest。我怎样才能达到那部分?有人可以帮助我吗?
{
"sol1" : 123,
"MyRequest" : {
}
}
this.getdata() 为我提供以下格式的数据。
{
"MyRequest":{
"Month":"",
"Number":"003254810"
}
}
我有另一个请求,我想将上面的 json 属性传递给 Myrequest。我怎样才能达到那部分?有人可以帮助我吗?
{
"sol1" : 123,
"MyRequest" : {
}
}
使用[]
添加property
如下。
var a = {
"MyRequest":{
"Month":"",
"Number":"003254810"
}
};
var b = {};
b['sol1'] = 123;
b['MyRequest'] = a.MyRequest;
console.log(b);
interface
你可以为你的请求的形状声明一个。
export interface SecondRequest {
solo: string;
MyRequest: {
Month: string;
number: string;
};
}
然后,只需分配MyRequest
给您的SecondRequst
对象。
secondRequest: SecondRequest = <SecondRequest>{};
...
this.secondRequest.MyRequest = MyRequest;