Last active
July 11, 2024 17:07
-
-
Save tehnrd/4559623 to your computer and use it in GitHub Desktop.
Getting values out of a JSON list of objects with Apex code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Object> fieldList = (List<Object>)JSON.deserializeUntyped('[{"field":"phone","object":"account"},{"field":"name","object":"account"}]'); | |
for(Object fld : fieldList){ | |
Map<String,Object> data = (Map<String,Object>)fld; | |
//Magic! | |
system.debug(data.get('field')); | |
} |
<aura:if isTrue="{!not(empty(v.values))}">
<div class="slds-table_header-fixed_container slds-scrollable_x" style="height:100%">
<div class="slds-scrollable_y" style="width:1160px">
<table role="grid" aria-rowcount="2" class="slds-table slds-table_header-fixed slds-table_bordered slds-table_edit" style="table-layout:fixed;width:1160px">
<thead>
<tr class="slds-line-height_reset">
<th scope="col" tabindex="-1" aria-label="" style="width:150px">
<div class="slds-cell-fixed" style="width: 150px;outline:none;">
<span class="slds-th__action">
<span class="slds-truncate">Gender</span>
</span>
</div>
</th>
<th scope="col" tabindex="0" aria-label="Name" style="width:100px">
<div class="slds-cell-fixed" style="width: 150px;outline:none;">
<span class="slds-th__action">
<span class="slds-truncate">Name</span>
</span>
</div>
</th>
<th scope="col" tabindex="0" aria-label="Last Name" style="width:100px">
<div class="slds-cell-fixed" style="width: 150px;outline:none;">
<span class="slds-th__action">
<span class="slds-truncate">Last Name</span>
</span>
</div>
</th>
<th scope="col" tabindex="0" aria-label="Name" style="width:100px">
<div class="slds-cell-fixed" style="width: 150px;outline:none;">
<span class="slds-th__action">
<span class="slds-truncate">First Name</span>
</span>
</div>
</th>
<th scope="col" tabindex="0" aria-label="Last Name" style="width:100px">
<div class="slds-cell-fixed" style="width: 150px;outline:none;">
<span class="slds-th__action">
<span class="slds-truncate">DOB</span>
</span>
</div>
</th>
<tbody>
<aura:iteration items="{!v.details}" var="item" indexVar="rowIndex">
<tr data-data="{!rowIndex}">
<td role="gridcell" tabindex="-1" data-label="Record Type Name">
<span class="slds-grid slds-grid_align-spread">
<div class="slds-truncate">
<span class="slds-truncate">{!item.gender}</span>
</div>
</span>
</td>
<td role="gridcell" tabindex="-1" data-label="Record Type Name">
<span class="slds-grid slds-grid_align-spread">
<div class="slds-truncate">
<span class="slds-truncate">{!item.name}</span>
</div>
</span>
</td>
<td role="gridcell" tabindex="-1" data-label="Record Type Name">
<span class="slds-grid slds-grid_align-spread">
<div class="slds-truncate">
<span class="slds-truncate">{!item.lastName}</span>
</div>
</span>
</td>
<td role="gridcell" tabindex="-1" data-label="Record Type Name">
<span class="slds-grid slds-grid_align-spread">
<div class="slds-truncate">
<span class="slds-truncate">{!item.firstName}</span>
</div>
</span>
</td>
<aura:iteration items="{!v.values.result}" var="result" indexVar="rowIndex">
<aura:iteration items="{!result.buildings}" var="buildings" indexVar="rowIndex">
<aura:iteration items="{!buildings.beds}" var="beds" indexVar="rowIndex">
<aura:if isTrue="{!item.gender == '!beds.gender'}">
<td role="gridcell" tabindex="-1" data-label="Record Type Name">
<span class="slds-grid slds-grid_align-spread">
<div class="slds-truncate">
<span class="slds-truncate">{!beds.dob}</span>
</div>
</span>
</td>
<aura:set attribute="else">
<td role="gridcell" tabindex="-1" data-label="Record Type Name">
<span class="slds-grid slds-grid_align-spread">
<div class="slds-truncate">
<span class="slds-truncate">No Dob</span>
</div>
</span>
</td>
</aura:set>
</aura:if>
</aura:iteration>
</aura:iteration>
</aura:iteration>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
</div>
</aura:if>
@dayan-naskar Thank you
After many hours of trying to figure out how to accomplish this..... I found this solution! Thanks a lot
Sick thank you
Worked like a charm! I've spent hours trying different solutions until I came upon this one which is so straightforward! Thank a lot!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
check the above one...