I need a simple code example showing javascript object and converting it to JSON.... I have done conversion based on javascript Array to JSON using $.ParseJSON(array mentioned here)....Now i need reverse of it...In the end I need to send it to the server using post method...Kindly Guide.
This code i got on internet...
var jsonArg1 = new Object();
jsonArg1.name = 'calc this';
jsonArg1.value = 3.1415;
var jsonArg2 = new Object();
jsonArg2.name = 'calc this again';
jsonArg2.value = 2.73;
var pluginArrayArg = new Array();
pluginArrayArg.push(jsonArg1);
pluginArrayArg.push(jsonArg2);
to convert pluginArrayArg (which is pure javascript array) into JSON array:
var jsonArray = JSON.parse(JSON.stringify(pluginArrayArg))
Here is one of the code that I saw on internet...but it seems as if in the start they are declaring JSON and not the assocaite array elements...Kindly guide me the proper way.Thanks