I Have a javascript code
var jsString1 = [];
var jsString = [];
var val1, val2;
val1 = "test1";
val2 = "test2";
jsString1.push("key1");
jsString1.push(val1);
jsString1.push("key2");
jsString1.push(val2);
jsString.push(jsString1);
alert(JSON.stringify(jsString));
this will give the result as these
// current output
[["key1","test1","key2","test2"]]
but I need to make one like these
// needed output
[{"key1":"test1","key2":"test2"}]
How can I do it ? Please help me and thanks in advance.