Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.

public class test5 {

public list<string> lststatename{get;set;}

public list<string> lstrating{get;set;}

public test5(){

string jsonexample1 = ' { "overalldata": [ {"stateName": "Andrapradesh", "rating": 5.0 }, { "stateName": "Telangana", "rating": 4.0 }, {"stateName": "Banglore", "rating": 5.0 } , {"stateName": "Maharastra", "rating": 4.5 } ] } ';

map<string,object> metadatamap= (map<string,object>)json.deserializeuntyped(jsonexample1);

list<object> values1= (list<object>)metadatamap.get('overalldata');

lststatename= new list<string>();

lstrating= new list<string>();

for(object parsed : values1){

map<string,object> values = (map<string,object>)parsed;

string statename = string.valueof(values.get('stateName'));

string rating= string.valueof(values.get('rating'));

lststatename.add(statename );

lstrating.add(rating);

}

}

}

visualforce page:

 

<apex:page controller="test5" >

<apex:form >

<table>

<tr>

<th>states</th>

<th>rating</th>

</tr>

<apex:repeat value="{!lststatename}" var="a">

<apex:repeat value="{!lstrating}" var="b">

<tr>

<td>{!a}</td>

<td>{!b}</td>

</tr>

</apex:repeat>

</apex:repeat>

</table>

</apex:form>

</apex:page>

hi ,  im getting the data  in the visualforce page , but the data is getting iterable when i use the repeat functionality inside the table , can anybody have the solution for this  ??it should not iterate again .. thanks in advance

 the data should not be get iterate again,

 
10 answers
  1. Sep 13, 2019, 12:09 PM
    Hi Deepika,

    One more update needs to be done. Please refer the below final updated code:

    public class test5 {

    public List<Overalldata> overalldata{get;set;}

    public test5(){

    string jsonexample1 = ' { "overalldata": [ {"stateName": "Andrapradesh", "rating": 5.0 }, { "stateName": "Telangana", "rating": 4.0 }, {"stateName": "Banglore", "rating": 5.0 } , {"stateName": "Maharastra", "rating": 4.5 } ] } ';

    overalldata = (List<Overalldata>)json.deserializeuntyped(jsonexample1);

    }

    //Wrapper class

    public class Overalldata {

    public String stateName;

    public Double rating;

    }

    }

    Also, find the attached image of the class in my org.

    User-added image

    Hope this will solve your problem.  If does then mark it as the best answer so it can also help others in the future.

    Many Thanks,

    Sunil Rathore

     
Loading
0/9000