Advanced JavaScript Training
Converting to JSON

Converting to JSON

  • To convert a JavaScript object to a JSON string, you can use the JSON.stringify() method. This is particularly useful when you need to send data to a server or store it in a file.
  

       const person = {
         name: 'Bob',
         age: 35
      };

      const personJSON = JSON.stringify(person);

      
Have a doubt?
Post it here, our mentors will help you out.