+ Start a Discussion
meghna nmeghna n 

display json array values

I have a json as follows.
[{"claimId":"M00234835","dateOfServiceBegin":"2018-12-31","legalOwnerName":"Joseph, Alice A","totalBilled":1000,"summary":"summary1","description":"descp1","dateTime":"2019-04-22T05:51:00.000Z","priority":"Low"},
{"claimId":"M00234834","dateOfServiceBegin":"2019-01-01","legalOwnerName":"Health 1st PC","totalBilled":1000,"summary":"","dateTime":"","priority":"Low"}]

I have a lightning component and in the markup I want to display the individual values of the above json.

so I am doing l like this.
<aura:attribute name="claimReworkRecords" type="Object" access="global" description="Claims Rework Data"/>

Now I am getting the entire JSON data into the above attribute I specified.

for(var i=0;i<claimsData.length;i++)
            {
                claimReworkRecords.push({
                    "claimId": claimsData[i].claimId,
                    "dateOfServiceBegin":claimsData[i].dateOfServiceBegin,
                    "legalOwnerName":claimsData[i].legalOwnerName,
                    "totalBilled":claimsData[i].totalBilled,
                    "dateTime":dateTime[i],
                    "priority":priority[i],
                    "summary":summary[i],
                    "description":description[i],
                })
            }

Now I want to display the individual values so in markup I am doing like this
 <aura:iteration items="{!v.claimReworkRecords}" var="claim" indexVar="indx">
            {!claim.claimId}
            {!claim.dateOfServiceBegin}
            
        </aura:iteration>

But its not displaying the individual values. Pleas let me know with correct code how I can achive this.

thanks
meghna
Best Answer chosen by meghna n
Ramesh DepaiahRamesh Depaiah
Hi @Meghna,
Component:
<aura:attribute name="claimReworkRecords" type="List" default="[]" />

<aura:iteration items="{!v.claimReworkRecords}" var="claim" indexVar="indx">
        {!claim.claimId}<br/>
        {!claim.dateOfServiceBegin}<br/>
         {!claim.legalOwnerName}
        
        
    </aura:iteration>
Controller:
init:function (component, event) {
        var mystr='Your jsonscript';
        component.set("v.claimReworkRecords", JSON.parse(mystr));  
    },
Output:
User-added image

I hope you find the above solution helpful. If it does mark as best answer to help others too.

Thanks,
Ramesh D

 

All Answers

Ramesh DepaiahRamesh Depaiah
Hi @Meghna,
Component:
<aura:attribute name="claimReworkRecords" type="List" default="[]" />

<aura:iteration items="{!v.claimReworkRecords}" var="claim" indexVar="indx">
        {!claim.claimId}<br/>
        {!claim.dateOfServiceBegin}<br/>
         {!claim.legalOwnerName}
        
        
    </aura:iteration>
Controller:
init:function (component, event) {
        var mystr='Your jsonscript';
        component.set("v.claimReworkRecords", JSON.parse(mystr));  
    },
Output:
User-added image

I hope you find the above solution helpful. If it does mark as best answer to help others too.

Thanks,
Ramesh D

 
This was selected as the best answer
meghna nmeghna n
@ Ramesh

Thanks that's working