0

I am getting below JSON as my response in Lightning.

[{
    "objRecord": {
        "Path_2_Description__c": "• You will complete the program and graduate with a degree/diploma\r\n• This process will take 2 years",
        "Path_3_Description__c": "• Upon graduation, get a degree/diploma, become eligible for post-graduation work permit\r\n• Work on Student Visa\r\n• Apply for post-graduation jobs and work\r\n• Find an Employer who can sponsor PR visa\r\n• This process will take 2 years",
        "Option_Code_Name__c": "Study,Work only and Return to India",
        "Path_1_Description__c": "• You will need to apply for admission from India to Canada and this will take 3 months to get an admission\r\n• Apply for a student visa from India to Canada. This process will take 3 months\r\n• Once you get a visa, you can travel to Canada and join the college",
        "Option_Code__c": "S-002 CAN",
        "Path_3__c": "Apply for post graduation jobs and work",
        "Path_2__c": "Attend College",
        "Id": "a4D590000008PmbEAE",
        "Path_1__c": "Apply for a Student VISA"
    },
    "icon": "utility:chevronright",
    "display": false,
    "rows": [{
        "**path**": "Apply for a Student VISA",
        "**description**": "• You will need to apply for admission from India to Canada and this will take 3 months to get an admission\r\n• Apply for a student visa from India to Canada. This process will take 3 months\r\n• Once you get a visa, you can travel to Canada and join the college"
    }, {
        "**path**": "Attend College",
        "**description**": "• You will complete the program and graduate with a degree/diploma\r\n• This process will take 2 years"
    }, {
        "**path**": "Apply for post graduation jobs and work",
        "**description**": "• Upon graduation, get a degree/diploma, become eligible for post-graduation work permit\r\n• Work on Student Visa\r\n• Apply for post-graduation jobs and work\r\n• Find an Employer who can sponsor PR visa\r\n• This process will take 2 years"
    }],
    "size": 3,
    "width": "1rem"
}]

I wanted to show the data in "path" and "description" (highlighted) in lightning component. I have tried in the following way but I see no data returning on component.

<div class="slds-grid slds-wrap">
    <aura:iteration items="{!v.mainRecords.rows.path}" var="mainRec">
        <div class="slds-col slds-size_1-of-6">
            {!mainRec}
         </div>
    </aura:iteration>
</div>

Can someone help me with this. Thanks in Advance....

1

The outer [] means this is an array. You need two iterators:

<aura:iteration items="{!v.mainRecords}" var="record">
  <aura:iteration items="{!record.rows}" var="mainRec">
    <div class="slds-col slds-size_1-of-6">
      {!mainRec}
     </div>
  </aura:iteration>
</aura:iteration>

Any time you have an array in your data structure, you're going to have an aura:iteration to display those values.

1
  • Thanks. It worked...
    – Vineeth
    Jul 22 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.