【发布时间】:2016-01-02 00:38:20
【问题描述】:
鉴于这个简化的场景:
export class LoginComponent{
grant_type: string="password";
jsonPayload: string;
Login(username, password){
this.jsonPayload = JSON.stringify(username, password, this.grant_type);
}
}
看起来 stringify 被 TypeScript 的“this”弄糊涂了。那么,我该如何制作格式正确的 JSON?
谢谢,
【问题讨论】:
标签: json typescript