> First question is, why do anything at all ? > > STON toStringPretty: <your game collector object> > > Then loading is as simple as > > STON fromString: '...'
I know :) Now I wanted to overuse STON to be able to edit manually the file too. > Next step is to customise how STON output is generated (but again, why ?). > > You do that by writing both an #stonOn: and a #fromSton: method (look for > implementors for examples). > > If you really want, you could get something like: > > GameCollector [ > GameItem { > #name : 'Final Fantasy X', > #console : #PS2, > #hasDocumentation : false, > #hasBox : true, > #finished : true, > #condition : 'Good', > #quotation : 10, > #critics : 18, > #comments : 'quite cool in fact' > }, > GameItem { > #name : 'Final Fantasy XII', > #console : '', > #hasDocumentation : true, > #hasBox : false, > #finished : false, > #condition : 'Good', > #quotation : 10, > #critics : 15, > #comments : '' > } > ] > > to work. > > Something like (untested): > > GameCollector>>stonOn: stonWriter > stonWriter writeObject: self do: [ > stonWriter encodeList: self items ] > > GameCollector class>>fromSton: stonReader > | collector | > collector := self new. > stonReader parseListDo: [ :each | > collector addGameItem: each ]. > ^ collector Thanks this is what I was looking for. :)