I have created below JSON in my servlet and sending Json back to ajax call in response.
I want to display Employee list in table. Please help me to retrieve value from JSON.
Thanks
{
  "First Name": "Last Name",
  "EmployeeList": [
    {
      "Ram": "Kumar"
    },
    {
      "Varun": "Kuamr"
    }
  ]
}
Below is my JSP COde.
$(document).ready(function() {
    $("#JsonStart").click(function(e) {
        e.preventDefault();
        alert("Hi");
        $.ajax({
            url: "/bin/getEmployee",
            method: "GET",
            success: function(myresponse) {
                alert("Inside Ajax" + myresponse);
                //    $("#ajaxResponse").text(myresponse);
                $("#ajaxResponse").html("");
                $("#ajaxResponse").append("<b>My Ajax Response :</b>" + myresponse);
                $.each(myresponse, function(key, value) {
                    alert("Value :" + value);
                    alert("Key :" + key);
                });
                console.log("success");
            },
            failure: function(myresponse) {
                CQ.Notification.notifyFromResponse(myresponse);
            }
        });
    });
});
<form>
    <div>
        <button type="button" id="JsonStart" name="Shareitem">TestJ</button>
    </div>
</form>
<div id="anotherSection">
    <fieldset>
        <legend>Response from jQuery Ajax Request</legend>
        <div id="ajaxResponse"></div>
    </fieldset>
</div>
Below is my servlet code :
public class EmployeeInfoServlet extends SlingSafeMethodsServlet {
     @Override
        protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException  {
                 JSONObject employeeJson = new JSONObject();
                 try {
                    employeeJson.put("EmployeeFirst", "Employee Last");
                        JSONArray empJsonArray = new JSONArray();
                            JSONObject Employee1=new JSONObject();
                            Employee1.put("Ram", "Kumar");
                            empJsonArray.put(Employee1);
                            JSONObject Employee2=new JSONObject();
                            Employee2.put("Varun", "Kuamr");
                            empJsonArray.put(Employee2);
                        employeeJson.put("EmployeeList", empJsonArray);
                        System.out.println("Employee JSON"+employeeJson.toString());
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                    response.setContentType("application/json");
                    response.setCharacterEncoding("UTF-8");
                    response.getWriter().write(employeeJson.toString());
     }
}
 
     
     
    