object to jsonObject and string

way to make json object

<script>
var main = new Array();
sub = new Object();    
sub['key1'] = 'value1';
sub['key2'] = 'value2';
sub['key3'] = 'value3';
main[0] = sub;

sub = new Object();    
sub['key1'] = 'value4';
sub['key2'] = 'value5';
sub['key3'] = 'value6';
main[1] = sub;


var jsonObject = {list:main};

alert(JSON.stringify(jsonObject));

</script>

Comments

Popular posts from this blog

Project euler 169 found clue

Floyd-Warshall's algorithm