Converting object and array in Javascript into JSON

Here is an method to convert Javascript Object in Javascript Array into JSON so that it can be passed in url

Let us create 2 Javascript objects as shown below

var json1= new Object();
    json1.name = 'test1';
    json1.value = 'value';
var json2= new Object();
    json2.name = 'test2';
    json2.value = 'value';


Then push the objects into Array as shown below


var fullArrayData= new Array();
fullArrayData.push(json1);
fullArrayData.push(json2);

And then convert the array into JSON as shown

var actualArray= JSON.parse(JSON.stringify(fullArrayData)) 

Then you can use the above variable “actualArray” in send url

Scroll to Top