jQuery with Json

by VENKATA VINAY BYSANI

HTML

<div>  </div>

<button id="alertJson">Alert JSon</button>

<button id="populate">Populate JSon</button>

JavaScript

$(document).ready(function()
  {
  $("#alertJson").click(function(){
   var obj = jQuery.parseJSON( '{ "name": "JSon" }' );
    alert( obj.name);
  });
      
   $("#populate").click(function(){
   var obj = jQuery.parseJSON( '[{ "key1": "value11","key2": "value12","key3": "value13"},{ "key1": "value21","key2": "value22","key3": "value23"},{ "key1": "value31","key2": "value32","key3": "value33"} ]' );
   $.each(obj, function(i, currentobj) {
  //use obj.id and obj.name here, for example:
  $("div").append(currentobj.key1+"<br>");
});
  });
});