wrap json in json field like a string - Javascript jQuery

Javascript examples for jQuery:Json

Description

wrap json in json field like a string

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> 
  <script type="text/javascript">
    $(function(){//from   ww  w.  j a  va 2  s  .  com
var foo = {
    field1: 1,
    field2: "someValue"
};
var foos = JSON.stringify(foo);
var bar = {
    requestBody: foos
};
var bars = JSON.stringify(bar);
$("#d").text(bars);
    });

      </script> 
 </head> 
 <body> 
  <div id="d"></div>  
 </body>
</html>

Related Tutorials