Hi sven

I'm coding with my son a game collector application :)
We want to save our collection with STON

So far we have

GameCollector asSTON >>

     String streamContents: [ :s | STON put: self onStreamPretty: s ]

and we get

GameCollector {
#items : OrderedCollection [
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 : ''
}
]
}

And this is good.
Now I wanted to use STON to save the items without the class structure

to get something like

OrderedCollection [
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 : ''
}
]


I coded as

GameCollector >> asSTON

     ^ String streamContents: [ :s | STON put: items onStreamPretty: s ]

and STON is not happy on reload.

I know that we are bending the rules.
Is there a way to do simply what I want?

I could leave also with

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 : ''
}

Stef

Reply via email to