I apologize if my title is inaccurate. I had the hardest time figuring out the terminology for this.

So my objective is to populate a table using json. I found this app online http://json2apex.herokuapp.com/

which let me create:

public with sharing class pricing {

        public List<Data> data;
        public Integer total;
        public Boolean success;

    public class Data {
        public Integer prodYrMth;
        public String srCrctp;
        public Integer speedInMbps;
        public String lata;
        public String state;
        public String zip;
        public String wc;
        public String affiliateFlag;
        public Integer cirCount;
        public Double totalCost;
        public Double avgCost;
        public Double medianCost;
        public Double minCost;
        public Double maxCost;
        public Double totalRev;
        public Double avgRev;
        public Double medianRev;
        public Double minRev;
        public Double maxRev;

    public List<Data> getData()
        return data;

    public static pricing parse(String json) {
        return (pricing) System.JSON.deserialize(json, pricing.class);

The code works fine in outputing to logs. What i'm struggling with is how to call this List and iterate through an lightning component table?

Something like:

public with sharing class testapex {
    public static pricing test()
        String json ='stuff';
        pricing obj = pricing.parse(json);
        pricing.Data[] jsonRecords = new List<pricing.Data>(obj.data);

            system.debug('jsonRecords:'+ jsonRecords.size());
            system.debug('jsonRecords:'+ jsonRecords);
            return jsonRecords;


<aura:attribute name="data" type="pricingJZ.Data[]" />
        <ui:button class="slds-button slds-button--brand" label="updateTable" press="{!c.echo2}"/>

<aura:component controller="testapex">

         <aura:iteration items="{!v.data}" var="data">



 {  echo : function(component) {
        var action = component.get("c.test");
        action.setCallback(this, function(response){
            component.set("v.data", response.getReturnValue());


i'm having issues getting any output in my table.even those logs shows the data is correct.

Edit: with latest attempt.



First off all you don't need to serialize it to json cause aura do it automatically.

    public List<Data> getData() { return data; }

On front end side

    <aura:iteration items="{!v.data}" var="entry">

JS server call you'll find here https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_actions_call.htm

| improve this answer | |

Based on my initial look it isnt clear to me what you are trying to do. You dont have to do a explicit JSON2Apex. you can instead create a wrapper class and pass the data from you apex method. how you pass data to your wrapper class is dependant totally on your logic. read about setting value for wrapper class. https://developer.salesforce.com/page/Wrapper_Class Once you set value for your wrapper class you access it in your client side controller and use your list attributes for aura:iteration. If you have any specific questions on what you want to do post that and folks here will help you out

| improve this answer | |

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.