[英]how to get data from multyline json object using Angular
After an $http get request resource api gives back a multyline json:(example) 在$ http获取请求资源api之后返回multyline json :(示例)
{"features":["type": "feature", "properties":{ "id": "001", "name": "Example"}]}
How can i get an id from that data? 我如何从该数据中获取ID?
$scope.myDate = $http.get('http://example.com/').
success(function(data, status){
var test = data.features;
$scope.information = test['type'];
}).
error(function(data, status){
console.log('not');
});
The way i used isn't correct, so any suggestions? 我使用的方式不正确,所以有什么建议吗? Thank you, in advance!
先感谢您!
Your JSON
is not valid, you need to change it as follows and then try 您的
JSON
无效,您需要按如下所示进行更改,然后尝试
var data = {
"features": [{
"type": "feature",
"properties": {
"id": "001",
"name": "Example"
}
}]
};
alert(data.features[0].type);
Note: features
array contains object, so you need to enclose that with {}
注意:
features
数组包含对象,因此您需要将其括在{}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.