I need to parse a table to JSON, I found this solution and it works:
var tab=[{"value":"1.0","label":"Alabama"},{"value":"2.0","label":"Alaska"}, {"value":"3.0","label":"American Samoa"}];
var myJsonString = JSON.stringify(tab);
var jsonData = $.parseJSON(myJsonString);
The problem is when I declare dynamically the two dimensional table 'tab' it doesn't work:
var tab_desc1= new Array(3);
tab_desc1[0]=new Array(2);
tab_desc1[0]["value"]="1.0";
tab_desc1[0]["label"]="Alabama";
tab_desc1[1]=new Array(2);
tab_desc1[1]["value"]="2.0";
tab_desc1[1]["label"]="Alaska";
tab_desc1[2]=new Array(2);
tab_desc1[2]["value"]="3.0";
tab_desc1[2]["label"]="American Samoa";
var myJsonString = JSON.stringify(tab_desc1);
var jsonData = $.parseJSON(myJsonString);
Logically my declaration contains error, bur I can't see it. Any help! Thanks.