• dEEPIKA SALESFORCE
  • NEWBIE
  • 55 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 17
    Replies
Hi, 
i have a json data, 
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" }  ] } ';

, it is deserilized and displayed in the table format with repeat functionality, onclick of the statename, should have to display the rating ,  without using selectlist and selectradio.

thanks 
deepika..
To display the value using  onclick , with the json data 

 
<apex:page controller="testclass2">
  
  <apex:form >
  <ul style="list-style-type: none;">
 
  <apex:repeat value="{!listwrap}" var="a">
  
      <li ><label>{!a.statevalue}</label></li>

 <apex:actionSupport event="onclick" action="{!test}"/>
         </apex:repeat>
        </ul>
  
  
   <apex:commandButton action="{!test}" value="Test" reRender="fm" />
   
   
    <apex:outputLabel id="fm">
    
      the selected value is  :
       
        
    </apex:outputLabel>
  </apex:form>
  
  
  
</apex:page>

Apex code:
 
public class testclass2 {
    public list<string> lststatename{get;set;}
    public list<string> lstrating{get;set;}
    public map<string, string> statemap {get;set;} 
    public list<string>selectedvalues{get;set;}
    public list<wrapperclass> listwrap {get;set;}
    public  testclass2 (){
        string  jsonexample1 =  ' { "data": [ {"stateName": "Andrapradesh",  "value": "apx" }, { "stateName": "Telangana",  "value":"tsx"}, {"stateName": "Banglore",  "value": "bngx"} , {"stateName": "Maharastra",  "value":"mhx" }  ] } ';
        listwrap = new list<wrapperclass>();
        map<string,object>  metadatamap= (map<string,object>)json.deserializeuntyped(jsonexample1); +
            system.debug(metadatamap.keyset());
        system.debug(metadatamap.values());
        list<object>  values1= (list<object>)metadatamap.get('data');
        lststatename= new list<string>();
        lstrating= new list<string>();
        statemap= new map<String, string>(); 
        
        for(object parsed : values1){
            map<string,object>  values = (map<string,object>)parsed;
            string statename = string.valueof(values.get('stateName'));
            string value = string.valueof(values.get('value'));
            lststatename.add(statename);
            statemap.put(statename, value);
        }
        
        for(String s :statemap.keyset()){
            wrapperclass w = new wrapperclass();
            w.selected = false;
            w.statevalue = s;
            listwrap.add(w);
        }
    }
    public void test(){
        
    }
    
    

public class wrapperclass{
    public boolean selected {get;set;}
    public string statevalue {get;set;}
}
}

Depending upon the selection or onclick , the value of the parttcular state should have to display..
Thanks and regards
Deepika subramanyam.
Hi, i need the display the values of the selected key using the onclick , action support, the value should be selected one at a time .. 
public class testclass2 {
    public list<string> lststatename{get;set;}
    public list<string> lstrating{get;set;}
    public map<string, string> statemap {get;set;} 
    public list<string>selectedvalues{get;set;}
    public list<wrapperclass> listwrap {get;set;}
    public  testclass2 (){
        string  jsonexample1 =  ' { "data": [ {"stateName": "Andrapradesh",  "value": "apx" }, { "stateName": "Telangana",  "value":"tsx"}, {"stateName": "Banglore",  "value": "bngx"} , {"stateName": "Maharastra",  "value":"mhx" }  ] } ';
        listwrap = new list<wrapperclass>();
        map<string,object>  metadatamap= (map<string,object>)json.deserializeuntyped(jsonexample1); +
            system.debug(metadatamap.keyset());
        system.debug(metadatamap.values());
        list<object>  values1= (list<object>)metadatamap.get('data');
        lststatename= new list<string>();
        lstrating= new list<string>();
        statemap= new map<String, string>(); 
        
        for(object parsed : values1){
            map<string,object>  values = (map<string,object>)parsed;
            string statename = string.valueof(values.get('stateName'));
            string value = string.valueof(values.get('value'));
            lststatename.add(statename);
            statemap.put(statename, value);
        }
        
        for(String s :statemap.keyset()){
            wrapperclass w = new wrapperclass();
            w.selected = false;
            w.statevalue = s;
            listwrap.add(w);
        }
    }
    public void test(){
        lstrating = new list<string>();
        for(wrapperclass wrap: listwrap){
            if(wrap.selected == true){
                lstrating.add(statemap.get(wrap.statevalue));
            }
        }
    }

public class wrapperclass{
    public boolean selected {get;set;}
    public string statevalue {get;set;}
}
}

Visualforce page:
 
<apex:page controller="testclass2">
  
  
  <apex:form >
  
  <ul style="list-style-type: none;">
 
  <apex:repeat value="{!listwrap}" var="a">
  
      <li ><label>{!a.statevalue}</label></li>

 <apex:actionSupport event="onclick" action="{!test}"/>
         </apex:repeat>
        </ul>
  
  
   <apex:commandButton action="{!test}" value="Test" reRender="fm" />
   
   
    <apex:outputLabel id="fm">
    
      the selected values are :
        <apex:repeat value="{!lstrating}" var="a">
            {!a}<br/>
        </apex:repeat>
    </apex:outputLabel>
  </apex:form>
  
  
  
</apex:page>

key is displayed in the values, on clicking of the key, the values should have to be displayed.  thank you .. in  advance
Hi i need to deserialize the json data into the selectlist , can any one please solve this issue..please .. 

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

 
    string  jsonexample1 =  ' { "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" }  ] } ';


how  to parse  the data and assign to Selectlist , itemlabel will be statename and itemvalue will be  rating, based on selection i should display the rating value .. can any one help out thank u ... 

thanks 
deepika
I am getting the popup but the issues are opening on double click, but the page is loading again and again ,and page is getting stop ..   
i need to display the popup using the commandbutton  form controllervalue  .. how can it be fixed?

Visualforce Page is:
 
<apex:page sidebar="false" controller="poputesting">
<apex:form >
 <html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"/>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
</html>


 <body>
 
 <!-- Button trigger modal -->

 
  


<apex:commandButton action="{!showPopup}" value="test" html-data-toggle="modal" html-data-target="#exampleModal" reRender="tstpopup" />


    <apex:outputPanel id="tstpopup">
      
            
            <apex:outputPanel rendered="{!displayPopup}"  layout="block" >
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

 </apex:outputPanel>
      </apex:outputPanel>
 </body>
 
 </apex:form>
</apex:page>

Apex class:

 
public class poputesting {


public boolean displayPopup {get; set;}
    
     public integer sucess{get;set;}     
    
    public void closePopup() { 
    
             
        displayPopup = false;    
    }     
    public void showPopup() {
    
    sucess =1;
    
     if( sucess ==1){
      displayPopup = true; 
     
     }
              
             
            
             
             
             system.debug(displayPopup);      
         
    }

}
I need to dispaly the popup using the salesforce command button , depending upon the sucess varible value from the controller .. 
public class poputesting {


public boolean displayPopup {get; set;}
    
     public integer sucess{get;set;}     
    
       
    public void showPopup() {
    
    sucess =1;
    if(sucess==1){
           displayPopup = true;     
             
             }        
         
    }

public void closePopup() { 
displayPopup = false; 
} 

}
 
<apex:page sidebar="false" controller="poputesting">
 <html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"/>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
</html>


 <body>
 
 <!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">

 
  Launch demo modal
</button>

<!-- <apex:commandButton action="{!showPopup}" value="lauch demo modal"/> -->
    <apex:outputPanel id="tstpopup">
        <apex:outputPanel layout="block" rendered="{!displayPopUp}"/>
            <apex:outputPanel layout="block" rendered="{!displayPopUp}">
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

 </apex:outputPanel>
      </apex:outputPanel>
 </body>
</apex:page>

i should display the popup depending upon the varible sucess, in controller ., thank you 

Deepika ..
//converted the blob image to base64.
 string paramvalue = EncodingUtil.base64Encode(imgeBody);
visualforcepage:
 
<apex:inputFilevalue="{!imgeBody}"  filename="{!imgefilename}"  > </apex:inputFile> 

public blob imgeBody{get;set;}
 public string imgefilename{get;set;}

   //converted to base64string 
  string paramvalue = EncodingUtil.base64Encode(imgeBody);
       
    
       // used rest callout  to post 
        gen.writestringField('imge', paramvalue);

  in respnse i got the base64 value , i had decoded it but it is not getting displyed can anybody solove this issue..

 
public string imagetest{get;set;}

 public blob getimage{get;set;}

//parsed data form the response 

if(jp.getcurrenttoken()==system.jsontoken.field_name && jp.gettext()=='img'){
        
        
        
        jp.nexttoken();
        
        
        
        imagetest = jp.gettext();  //base64 stirng is stored .
        
        getimage =EncodingUtil.base64Decode(imagetest ); 
        
      
        
        }


visualforce page:


<apex:image value="{!getimage}" alt="your image"   /> 
i have done image to base64 and while decoding it and displaying it was not displaying may i know how to solve this thanks ..


 
public class class2 {

 public list<string> lststatename{get;set;}
       
       public list<string> lstrating{get;set;}
       
        public map<string, string>statemap{get;set;} 
        
        
          public list<string>selectedvalues{get;set;}

 public  class2(){
 
 
 
 
 
      string  jsonexample1 =  ' { "data": [ {"stateName": "Andrapradesh",  "value": "apx" }, { "stateName": "Telangana",  "value":"tsx"}, {"stateName": "Banglore",  "value": "bngx"} , {"stateName": "Maharastra",  "value":"mhx" }  ] } ';
       

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

    list<object>  values1= (list<object>)metadatamap.get('data');  
    
     lststatename= new list<string>();
    
    lstrating= new list<string>();
    
         statemap= new map<String, string>(); 
        
        
          for(object parsed : values1){
          
             map<string,object>  values = (map<string,object>)parsed;
          
          string statename = string.valueof(values.get('stateName'));
          
          
          string value = string.valueof(values.get('value'));
          
          
          lststatename.add(statename);
          
          
       
          
          
           statemap.put(statename, value);
}


 }
 
 
 
   public PageReference test(){
   
  
   
   //code to be written 
   
   
   
    return null;
   
   
   
   }
}
 
<apex:page controller="class2">
  
  
  <apex:form >
  
  <ul style="list-style-type: none;">
 
  <apex:repeat value="{!lststatename}" var="a">
      <li ><apex:inputCheckbox value="{!statemap[a]}" /><label>{!a}</label></li>
        </apex:repeat>
        </ul>
  
  
   <apex:commandButton action="{!test}" value="Test" reRender="fm"/>
   
   
    <apex:outputLabel id="fm">
    
      the selected values are :
    </apex:outputLabel>
  </apex:form>
  
  
</apex:page>

User-added image

onclicking on the test button , the values are to be displayed, how to achieve this functionality ?

Thanks in advance
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);
            
             }
       
 }
}
 
<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>

User-added image
 here to use the html table to display the values, but the data is getting iterated again , Any body have any idea to handle this. thanks in advance .. 
i have a path , it should have to show using the apex image , any idea to show the path , the path changes dynamically so i think it can be stored to static resource in salesforce ..thank u
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,
 
string jsonexample1 = ' { "states" : [ "india", "alaska", "china" ] } ';


how to parse the data in the picklist in the apex:repeat functionalities , 

Another scenario :

 if the data is 

 string jsonexample2 =  ' { "overalldata": [ {"stateName": "Andrapradesh",  "taxpercent": 15.0 }, { "stateName": "Telangana",  "taxpercent": 18.0 }, {"stateName": "Banglore",  "taxpercent": 16.0 } , {"stateName": "Maharastra",  "taxpercent": 14.0 }  ] } '; 


here i need to get the statename in the picklist and taxpercent in a  Repeat table .. can anybody guide me how to proceed thanks ... 






 
i need to pass the data and image in the rest callout ? any help?
how to send the image in salesforce rest callout using <inpu
<div >
                                            <apex:inputFile  value="" ></apex:inputFile> 
                                         
                             <input type="button" c value=" Choose File" />
                                            <span class="file-info">  No file Chosen</span>
                                        </div>

i should have to select a image form the choose file  and send in the form of json .. to the third party api , how it should process,in the json Post request?

and later to preview using the Get request..? 


 
<apex:page >
  
  <apex:form >
  
  <html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
 $(document).ready(function() {

    $("#name").focusout(function() {
       
         var value =$('#name').val();
         
          if(value==""){
          
                   $('#name_Error').html(" name is Required!");

          }else{
           $('#name_Error').empty();
          
          return true;
          }
    });

});
</script>
</head>
<body>


 <input type="text"  id="name"/><span id="name_Error" class="Errormessage"></span>
 
 <br/>
<apex:inputText styleClass="form-control" html-placeholder="Name"  id="name" /><span id="name_Error" class="Errormessage"></span>

</body>
</html>
</apex:form>
</apex:page>

Hi , here iam using the html input  , the jquery is working , when iam using the apex:input text, the value is not working ?? may i get any solution ?
system.jsonGenerator jpp =  json.CreateGenerator(true);
         
            jpp.writeStartobject();
        
     
            
             jpp.writestringfield('Name',null);
       
            
          jpp.writeEndobject();
 
 
 
          jsonstring1 = jpp.getAsString();

how go get the value of the name as null in the jsonformat :
i.e  
 
              { "Name" : null }

  can anybody suggest how to get the value .
    string  jsonexample1 =  ' { "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" }  ] } ';


how  to parse  the data and assign to Selectlist , itemlabel will be statename and itemvalue will be  rating, based on selection i should display the rating value .. can any one help out thank u ... 

thanks 
deepika
//converted the blob image to base64.
 string paramvalue = EncodingUtil.base64Encode(imgeBody);
visualforcepage:
 
<apex:inputFilevalue="{!imgeBody}"  filename="{!imgefilename}"  > </apex:inputFile> 

public blob imgeBody{get;set;}
 public string imgefilename{get;set;}

   //converted to base64string 
  string paramvalue = EncodingUtil.base64Encode(imgeBody);
       
    
       // used rest callout  to post 
        gen.writestringField('imge', paramvalue);

  in respnse i got the base64 value , i had decoded it but it is not getting displyed can anybody solove this issue..

 
public string imagetest{get;set;}

 public blob getimage{get;set;}

//parsed data form the response 

if(jp.getcurrenttoken()==system.jsontoken.field_name && jp.gettext()=='img'){
        
        
        
        jp.nexttoken();
        
        
        
        imagetest = jp.gettext();  //base64 stirng is stored .
        
        getimage =EncodingUtil.base64Decode(imagetest ); 
        
      
        
        }


visualforce page:


<apex:image value="{!getimage}" alt="your image"   /> 
i have done image to base64 and while decoding it and displaying it was not displaying may i know how to solve this thanks ..


 
public class class2 {

 public list<string> lststatename{get;set;}
       
       public list<string> lstrating{get;set;}
       
        public map<string, string>statemap{get;set;} 
        
        
          public list<string>selectedvalues{get;set;}

 public  class2(){
 
 
 
 
 
      string  jsonexample1 =  ' { "data": [ {"stateName": "Andrapradesh",  "value": "apx" }, { "stateName": "Telangana",  "value":"tsx"}, {"stateName": "Banglore",  "value": "bngx"} , {"stateName": "Maharastra",  "value":"mhx" }  ] } ';
       

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

    list<object>  values1= (list<object>)metadatamap.get('data');  
    
     lststatename= new list<string>();
    
    lstrating= new list<string>();
    
         statemap= new map<String, string>(); 
        
        
          for(object parsed : values1){
          
             map<string,object>  values = (map<string,object>)parsed;
          
          string statename = string.valueof(values.get('stateName'));
          
          
          string value = string.valueof(values.get('value'));
          
          
          lststatename.add(statename);
          
          
       
          
          
           statemap.put(statename, value);
}


 }
 
 
 
   public PageReference test(){
   
  
   
   //code to be written 
   
   
   
    return null;
   
   
   
   }
}
 
<apex:page controller="class2">
  
  
  <apex:form >
  
  <ul style="list-style-type: none;">
 
  <apex:repeat value="{!lststatename}" var="a">
      <li ><apex:inputCheckbox value="{!statemap[a]}" /><label>{!a}</label></li>
        </apex:repeat>
        </ul>
  
  
   <apex:commandButton action="{!test}" value="Test" reRender="fm"/>
   
   
    <apex:outputLabel id="fm">
    
      the selected values are :
    </apex:outputLabel>
  </apex:form>
  
  
</apex:page>

User-added image

onclicking on the test button , the values are to be displayed, how to achieve this functionality ?

Thanks in advance
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);
            
             }
       
 }
}
 
<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>

User-added image
 here to use the html table to display the values, but the data is getting iterated again , Any body have any idea to handle this. thanks in advance .. 
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,
 
string jsonexample1 = ' { "states" : [ "india", "alaska", "china" ] } ';


how to parse the data in the picklist in the apex:repeat functionalities , 

Another scenario :

 if the data is 

 string jsonexample2 =  ' { "overalldata": [ {"stateName": "Andrapradesh",  "taxpercent": 15.0 }, { "stateName": "Telangana",  "taxpercent": 18.0 }, {"stateName": "Banglore",  "taxpercent": 16.0 } , {"stateName": "Maharastra",  "taxpercent": 14.0 }  ] } '; 


here i need to get the statename in the picklist and taxpercent in a  Repeat table .. can anybody guide me how to proceed thanks ... 






 
i need to pass the data and image in the rest callout ? any help?
<apex:page >
  
  <apex:form >
  
  <html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
 $(document).ready(function() {

    $("#name").focusout(function() {
       
         var value =$('#name').val();
         
          if(value==""){
          
                   $('#name_Error').html(" name is Required!");

          }else{
           $('#name_Error').empty();
          
          return true;
          }
    });

});
</script>
</head>
<body>


 <input type="text"  id="name"/><span id="name_Error" class="Errormessage"></span>
 
 <br/>
<apex:inputText styleClass="form-control" html-placeholder="Name"  id="name" /><span id="name_Error" class="Errormessage"></span>

</body>
</html>
</apex:form>
</apex:page>

Hi , here iam using the html input  , the jquery is working , when iam using the apex:input text, the value is not working ?? may i get any solution ?
system.jsonGenerator jpp =  json.CreateGenerator(true);
         
            jpp.writeStartobject();
        
     
            
             jpp.writestringfield('Name',null);
       
            
          jpp.writeEndobject();
 
 
 
          jsonstring1 = jpp.getAsString();

how go get the value of the name as null in the jsonformat :
i.e  
 
              { "Name" : null }

  can anybody suggest how to get the value .