function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vigoroushakevigoroushake 

Accessing elements of a list made from a deserialized JSON string

In my controller code I have the following list of objects generated from a deserialized JSON string:

(InventoryInfo:[locationId=89, skuNxtOrderDate=, skuQty=266, skuQtyOnOrder=], InventoryInfo:[locationId=95, skuNxtOrderDate=2015-08-19, skuQty=0, skuQtyOnOrder=0], InventoryInfo:[locationId=96, skuNxtOrderDate=2015-08-19, skuQty=0, skuQtyOnOrder=0], InventoryInfo:[locationId=97, skuNxtOrderDate=2015-08-19, skuQty=0, skuQtyOnOrder=0], InventoryInfo:[locationId=98, skuNxtOrderDate=2015-08-19, skuQty=0, skuQtyOnOrder=0])

In my controller code I can access any element by giving the row number and the element name, e.g., InventoryInfo[0].locationId returns 89 as the value.

Once I pass the above through to my VF page I can't seem to access the elements in the same manner:

<table id="inventorytable" class="display" >  
            <thead>
                <tr>
                    <th>Warehouse</th>
                    <th>On Hand</th>
                    <th>On Order</th>
                    <th>Next PO Date</th>
                    <th>Next Expected Quantity</th>
                    </tr>
            </thead>
            <tbody>
                <apex:repeat value="{!inventoryInfoList}" var="inventoryInfo">                
                    <tr>                       
                       <td>{!inventoryInfo.locationId}</td>
                       <td>{!inventoryItem.skuQty}</td>
                        <td>{!inventoryItem.skuQtyOnOrder}</td>
                        <td>{!inventoryItem.skuNxtOrderDate}</td>
                    </tr>
                </apex:repeat>
            </tbody> 
        </table>

When I attempt to access {!inventoryItem.locationId} (similar to how I had accessed on the controller side) I get an unknown property error.  If try to access {!InventoryItem[0]} it returns the first inventory item row with all the attributes such as locationId, skuQty, etc. However, I need to access these atrtributes individually and I'm not sure how to do so.

Thanks in advance for any pointers!





 
vigoroushakevigoroushake
When I pass the List built from the deserialized JSON from my controller to my VF page it looks like this:

[InventoryInfo:[locationId=89, skuNxtOrderDate=, skuQty=266, skuQtyOnOrder=], InventoryInfo:[locationId=95, skuNxtOrderDate=2015-08-19, skuQty=0, skuQtyOnOrder=0], InventoryInfo:[locationId=96, skuNxtOrderDate=2015-08-19, skuQty=0, skuQtyOnOrder=0], InventoryInfo:[locationId=97, skuNxtOrderDate=2015-08-19, skuQty=0, skuQtyOnOrder=0], InventoryInfo:[locationId=98, skuNxtOrderDate=2015-08-19, skuQty=0, skuQtyOnOrder=0]]
vigoroushakevigoroushake
Updated my InventoryInfo class with getters and setters:

public class InventoryInfo{

    public String locationId {get; private set;}

    public String skuQtyOnOrder {get; private set;}

    public String skuNxtOrderDate {get; private set;}

    public String skuQty {get; private set;}

    }

Solved issue!