Send object array to Json and parse back to object - Javascript JSon

Javascript examples for JSon:JSon Parse

Description

Send object array to Json and parse back to object

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head> 
      <title>  Morkel King</title> 
   </head> 
   <body translate="no"> 
      <script>
      const jsObjectArray = [/*w w w  .  java 2  s .c  om*/
  {name: "Homer", age:56 },
  {name: "Marge", age:50 },
];
const buf = JSON.stringify(jsObjectArray);

console.log("String: "+buf);

// convert it back to an object
const newObject = JSON.parse(buf);
console.log("object: "+newObject);
    
      </script>  
   </body>
</html>

Related Tutorials