Skip to content

JSON stringify to array JavaScript | Example code

  • by

JSON stringify method converts a JavaScript object into a string (not an array).

JSON.stringify(value)

Example JSON stringify to array JavaScript

Simple HTML example code use the JavaScript function JSON.stringify() to convert it into a string. The output will be a string following the JSON notation.

  <!DOCTYPE html>
  <html>
  <head>

    <script>
      var person={"first_name":"Tony","last_name":"Hawk","age":31};
      console.log(person);
      
      var res = JSON.stringify(person); 

      console.log(res);
      console.log(typeof(res))
    </script>

  </head>
  </html>

Output: Person is now a string, and ready to be sent to a server:

JSON stringify to array JavaScript

Do comment if you have any doubts or suggestions on this JS Array JSNO topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading