You need to sign in to do that
Don't have an account?
Deepikareddy
selectlist in salesforce
Hi i need to deserialize the json data into the selectlist , can any one please solve this issue..please ..
Apex Class is :
Visualforce page is:
in the above selecoptions, the itemlabel wil be stateName and itemvalue is rating.. please help to solve this issue..
thanks and regards
deepika
Apex Class is :
public class test10 { public List<SelectOption> options {get;set;} public test10(){ check(); } //wrapperclass1 public class ContactWrapper { public string stateName{ get; set; } public string rating{get;set;} } public class overalldata { public List<ContactWrapper> overalldata; } public void check(){ overalldata conList = new overalldata(); string jsonstring='{ "sucess":1, "overalldata": [ {"stateName": "Andrapradesh", "rating": "5.0" , "active": "yes" }, { "stateName": "Telangana", "rating": "4.0" ,"active": "no" }, {"stateName": "Banglore", "rating": "5.0" ,"active": "no"} , {"stateName": "Maharastra", "rating": "4.5" ,"active": "no" } ] } '; conList = (overalldata)System.JSON.deserialize(jsonstring, overalldata.class); System.debug('Respone- ' + conList); //getting data as this //10:25:35:007 USER_DEBUG [31]|DEBUG|Respone- overalldata:[overalldata=(ContactWrapper:[rating=5.0, stateName=Andrapradesh], ContactWrapper:[rating=4.0, stateName=Telangana], ContactWrapper:[rating=5.0, stateName=Banglore], ContactWrapper:[rating=4.5, stateName=Maharastra])] } }
Visualforce page is:
<apex:page controller="test10"> <apex:form > <apex:selectList > <apex:selectOptions value="{!options}"/> </apex:selectList> </apex:form> </apex:page>
in the above selecoptions, the itemlabel wil be stateName and itemvalue is rating.. please help to solve this issue..
thanks and regards
deepika
Please try below code.
Mark as resolved if you find this answer helpful..
All Answers
Please try below code.
Mark as resolved if you find this answer helpful..
Greetings to you!
Use the below links through which you may get help:
https://salesforce.stackexchange.com/questions/186063/display-json-data-in-inputfield-on-dropdown-change
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com