parse json object returned in javascript - Javascript JSon

Javascript examples for JSon:JSon stringify

Description

parse json object returned in javascript

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from w  ww .  jav a 2 s  . c o m*/
    var responseText='{ message_type="oauth2_complete", code="asdf123asdf234sdf234sdf234sdf234", state="robot" }';
    var parsedResponse={};
    responseText.replace(/(\w+?)="([^"]*)"/g,function($0,$1,$2){parsedResponse[$1]=$2;});
    console.log(parsedResponse);
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials