【发布时间】:2017-09-23 01:30:02
【问题描述】:
我有一个 JSON 数组,想将它粘贴到 typescript 中的数组变量中。
我从http://www.example.com/select.php 收到的 JSON:
{
"User":[
{"Name":"Luca M","ID":"1"},
{"Name":"Tim S","ID":"2"},
{"Name":"Lucas W","ID":"3"}
]
}
我想要一个这样的数组:
this.items = [
'Luca M',
'Tim S',
'Lucas W'
];
编辑:
当前代码是
this.http.post('http://www.example.com/select.php', creds, {
headers: headers
})
.map(res => res.json().User)
.subscribe(
data => this.data = data.User.map(user => user.Name),
err => this.logError(err),
() => console.log('Completed')
);
this.items = this.data;
错误:
无法读取未定义的属性“地图”
我怎样才能意识到这一点?
感谢和问候
【问题讨论】:
标签: arrays json typescript ionic2