D-styled data file

Saaa empty at needmail.com
Wed Apr 29 18:57:08 PDT 2009


This is what I came up with to save a multidimentional array in JSON.
It compiles . . but does not work : )


int[100][100][10] bigArray;

//set the array to something other then zero
foreach( int[100][100] arr; bigArray)
  foreach(int index, int[100] miniarr; arr)
    miniarr[] = index;

auto json = new Json!(char);

with (json)
foreach(int index, int[100][100] arr; bigArray)
  foreach(int index2, int[100] miniarr; arr)
    value = object (pair("data_"~Conv.toString(index)~Conv.toString(index2), 
array(miniarr[0])));
//I want to save the whole array of course but array() doesn't take an array 
as such, I think.
//Also I only get one pair (which is nicely named data_999 )

auto outfile = new File("/data.dat");
json.print ((char[] s) {outfile.write(s);});
json.print ((char[] s) {Cout(s);});




More information about the Digitalmars-d-learn mailing list