If you want a strintg or text to convert into json object than 
  		 var txt ='{"token":true,"name":"John", "age":30, "city":"New York"}'
   		 var obj = JSON.parse(txt);
   
  
 here var text is a string and using JSON.parse() function convert into a json object
Try Your self
this code is work in backend of button!
 
    $("button").click(function(){
     	 var txt ='{"token":true,"name":"John", "age":30, "city":"New York"}'
    	 var obj = JSON.parse(txt);
          if(obj.token){
             alert(obj+"Obj contain ="+txt);
          }
    });
  });
  
  
0 Comments