angular4读取JSON数据

直接上代码:

确保json是可访问的

http://localhost:54843/dist/appsettings.json文件

{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"freetrial": {
"id": "01",
"imgurl": "images/1.jpg",
"status": "0"
}
}

http请求:

this.http.get(url).subscribe(data => {
console.log(data);
let url = data.json().Logging;
let urlss = data.json().Logging.IncludeScopes;
let xx = data.json().freetrial.id;
let sTaskName = data.json()["Logging"];

});

posted @ 2017-09-13 22:56  914556495  阅读(1191)  评论(0编辑  收藏  举报