title: How to search and retrieve data from json file in Jquery?
body: <p>I have a json file with below data.</p>
  
  <pre><code>{"student1":[{"id":1,"name":"Test Data1","email":"test1@g.com"}]}
  
  {"student2":[{"id":2,"name":"Test Data2","email":"test2@g.com"}]}
  
  {"student3":[{"id":3,"name":"Test Data3","email":"test3@g.com"}]}
  
  {"student4":[{"id":4,"name":"Test Data4","email":"test4@g.com"}]}
  </code></pre>
  
  <p>And I use $.getJSON method to retrieve but data won't output. And I want to search data with Key like student3, then the data of student3 will have to output.
  Here is my JQuery code. </p>
  
  <pre><code>$.getJSON( "test.json", function( data ) {
            var items = [];
            $.each( data, function( key, val ) {
              items.push( "&lt;li id='" + key + "'&gt;" + val + "&lt;/li&gt;" );
            });
  
            $( "&lt;ul/&gt;", {
              "class": "my-new-list",
              html: items.join( "" )
            }).appendTo( "body" );
      });
  </code></pre>
  
  <p>Here is my Full Source Code.</p>
  
  <pre><code> &lt;!DOCTYPE html&gt;
   &lt;html&gt;
     &lt;head&gt;
       &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"&gt;&lt;/script&gt;
     &lt;title&gt;Test Json&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
       &lt;input type="text" name="name" id="name"&gt;
       &lt;input type="text" name="email" id="email"&gt;
       &lt;input type="button" name="submit" id="submit" value="Submit" onclick="submitForm()"&gt;
       &lt;input type="button" name="edit" id="edit" value="Edit" onclick="Edit()"&gt;
       &lt;br&gt;&lt;br&gt;
       &lt;div&gt;&lt;/div&gt;
   &lt;/body&gt;
  
   &lt;script type="text/javascript"&gt;
      function submitForm(){
      var name = $("#name").val();
      var email = $("#email").val();
      var obj = {
         table: []
      };
      obj.table.push({id: 1, name:name, email:email});
      var json = JSON.stringify(obj);
      $.ajax
      ({
          type: "GET",
          dataType : 'json',
          url: 'save_json.php',
          data: { data: json },
          success: function () {alert("Thanks!"); },
          failure: function() {alert("Error!");}
      });
      $("#name").val('');
      $("#email").val('');
  }
  
  
    function Edit(){
      $.getJSON( "general.json", function( data ) {
  
            var items = [];
            $.each( data, function( key, val ) {
              items.push( "&lt;li id='" + key + "'&gt;" + val + "&lt;/li&gt;" );
            });
  
            $( "&lt;ul/&gt;", {
              "class": "my-new-list",
              html: items.join( "" )
            }).appendTo( "body" );
      });
     }
   &lt;/script&gt;
   &lt;/html&gt;
  </code></pre>