I have a javascript object with 6 key value pairs:
My_Type_1:"Vegetable"
My_Type_2:"Fruit"
My_Type_3:"Dessert"
My_Value_1: "Carrot"
My_Value_2: "Apple"
My_Value_3: "Cake"
I want to construct JSON out of the above object such that it generates the following:
[{"Vegetable":"Carrot"},{"Fruit":"Apple"},{"Dessert":"Cake"}]
EDIT:
for (j=0;j<3;j++)
{
var tvArray = new Array();
var sType = 'My_Type_'+j+1;
var sValue = 'My_Value_'+j+1;
tvArray['Type'] = JSObject[sType];
tvArray['Value'] = JSObject[sValue];
}
The json.stringify doesn't produce the desired output as listed above.
How do I do this?
Thanks