Convert Javascript Object to JSON string


You can use the following procedure to convert JS object to JSON string


var myObject = {
  "myKey1": "MyValue1",
  "myKey2": "MyValue2",
  "myKey3": "MyValue3"

var jsonStr = JSON.stringify(myObject);

above code will convert myObject JS object to Json string and assign it to jsonStr variable

Leave a Reply

(*) Required, Your email will not be published