"Saaa" <em...@needmail.com> wrote in message news:gtlrs3$1b9...@digitalmars.com... > > I looked at the JSON format and it seems very inefficient at loading > arrays as it isn't limited to one type per array. > This is nice when you want to save a small array with different typed > elements but for my purposes this is kind of a performance problem. > > This is why I will try and get suggestions again about the D-styled format > I tried to suggest a few threads ago :) > > Let me suggest a simple example: > (Please tell me when something isn't obvious :) > > ---file.dat > //comment > int number = 10; > > float [3][2] simpleArray = [ > [0.1, 0.2, 0.3], > [0.4, 0.5, 0.6]]; > -- > > ---main.d > static import ddata; > void main() > { > char[][] file = read (`file.dat`); > int i; > char c; > > ddata.get(file,'number',i); > ddata.get(file,'number',c); //type fail, thus returns -1 or throws an > exception > > float [3][2] a; > > ddata.get(file,'simpleArray',a); > ddata.write(file,'simpleArrayCopy', a); > > a[0][0] =3.0; > > ddata.write(file,'simpleArray', a); > > write('file.dat', file); > } > -- > > resulting data file: > > ---file.dat > //comment > int number = 10; > > float [3][2] simpleArray = [ > [3.0, 0.2, 0.3], > [0.4, 0.5, 0.6]]; > > float [3][2] simpleArrayCopy = [ > [0.1, 0.2, 0.3], > [0.4, 0.5, 0.6]]; > -- > >
I've run into similar problems when I wanted to save lots of stuff to a file, and be able to load them again. Huge multi-dimensional arrays seem to be an issue with JSON and similar.. Such a file writer as you propose would be very handy to have.