Skip to content

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(); = 'test1';
    json1.value = 'value';
var json2= new Object(); = 'test2';
    json2.value = 'value';

Then push the objects into Array as shown below

var fullArrayData= new Array();

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