I am getting values together from one key. Because in my case multiple values in array form come into the one key.
JSON
engine_data: {
internal: {
poling: {
account: [
"2009-38554",
"2009-38554"
],
secure: [
"2008-11833"
]
}
}
}
Javascript:
call.all('xyz').get(id).then(function(resp)
{
var res=resp.data;
var jsonData =
res.engine_data.internal.poling;
for(var i in jsonData){
if(i == "account")
{
alert(jsonData[i]);
alert(jsonData[i].length);
var account = jsonData[i].join(",")
$scope.acount = www.xyz/+account;
}if (i == "secure") {
var secure = jsonData[i].join(",")
$scope.secure = www.abc/+secure;
}
}
In my Json value in array form, So account (keys) has two value in array form. When I put in alert for printing then both value print together.
So I want to append these two value in www.xyz/ url.
Like out put result should be
www.xyz/2009-38554
www.xyz/2009-38554
But Right now I am getting
www.xyz/2009-38554,2009-38554
Share your ideas thanks in advance.
you can iterate over the array you get from account
key and make all possible urls you can form values in array and you can make $scope.account
an array and push all possible combinations, something like this:
for(var i in jsonData){
if(i == "account")
{
alert(jsonData[i]);
alert(jsonData[i].length);
$scope.account = [];
var account = jsonData[i];
for(var i=0; i<account.length; i++)
$scope.acount.push("www.xyz/"+account[i]);
}if (i == "secure") {
var secure = jsonData[i].join(",")
$scope.secure = www.abc/+secure;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.