You need to sign in to do that
Don't have an account?

read json array values
I have json arrya as follows inside lightning component controller
var allResultsArray=JSON.stringify(component.get("v.allResults"));
[{"Name":"Cardiology","Code":"839"},{"Name":"Pediatric Cardiology","Code":"824"},{"Name":"Cardiothoracic Surgery","Code":"701"},{"Name":"Interventional Cardiology","Code":"726"},{"Name":"Pediatric Cardiothoracic Surgery","Code":"707"}]
var isName,isCode;
I want to read the Name and Code in variables
I am doing as follows
for(var i=0;i<allResultsArray.length;i++)
{
isName =allResultsArray[i].Name;
alert(isName);
}
But I am not able to get the vauies of Name and Code from the above json array
please let me know how I can achieve this.
thanks
Meghna
var allResultsArray=JSON.stringify(component.get("v.allResults"));
[{"Name":"Cardiology","Code":"839"},{"Name":"Pediatric Cardiology","Code":"824"},{"Name":"Cardiothoracic Surgery","Code":"701"},{"Name":"Interventional Cardiology","Code":"726"},{"Name":"Pediatric Cardiothoracic Surgery","Code":"707"}]
var isName,isCode;
I want to read the Name and Code in variables
I am doing as follows
for(var i=0;i<allResultsArray.length;i++)
{
isName =allResultsArray[i].Name;
alert(isName);
}
But I am not able to get the vauies of Name and Code from the above json array
please let me know how I can achieve this.
thanks
Meghna
Please try below code it will work for your requirement Thank You
www.nubeselite.com
Developement | Training | Consulting
Please mark this as solution if your problem resolved.
The JSON I shown does not contain "overalldata", You have added it to my JSON and shown code but I cannot do the same in my lightning component.
can u pls show again without using " overalldata"?
thanks
Meghna