{
cardAid:ALPHG,
displayName:ALPHG,
port:A
}
{
cardAid:ALPHG,
displayName:ALPHG,
port:B
}
{
cardAid:SFD,
displayName:SFD
port:C
}
{
cardAid:SFD,
displayName:SFD
port:D
}
{
cardAid:ARR,
displayName:ARR
port:E
}
HI, i have a JSON as above, I'm tring to iterate thrugh the JSON to get output as CardName:ALPHG Count:2 port:A,B Cardname:SFD Count:2 Port:C,D CardName:ARR Count:1 Port:E
var map = new Object;
var count=0;
for(var index=0;index<arr.length;index++)
{
countOfPort.push({name: arr[index].cardAid.trim()});
}
for(var index=0;index<countOfPort.length;index++)
{
for(var i=0;i<arr.length;i++)
{
try{
if(countOfPort[index].name == arr[i].cardAid)
{
count++;
map.cardName = countOfPort[index].name;
}
map.portCount=count;
}
catch(e)
{
console.log("exception"+e);
}
}
}
return map;
}
I'm using the following code which is giving the o/p as, CardName:ALPHG Count:1 port:A Cardname:ALPHG Count:1 Port:B CardName:SFD Count:1 Port:C