On 17/05/2017 13:46, Sven Van Caekenberghe wrote:
On 17 May 2017, at 12:44, Sven Van Caekenberghe <sven@stfx.eu> wrote:
Hi Cyril,
This can be done quite easily in STON, I will make you a small example and add it to the unit tests.
=== Name: STON-Tests-SvenVanCaekenberghe.79 Author: SvenVanCaekenberghe Time: 17 May 2017, 1:43:03.944446 pm UUID: fb472e87-180c-0d00-b559-fec60aee7555 Ancestors: STON-Tests-SvenVanCaekenberghe.78
Add STONWriteReadTests>>#testKnownObjects as an example of how to serialize only an ID and resolve that ID upon materialization
Add STONTestKnownObject with custom #stonOn: and class side #fromSton: ===
You basically (over)write 2 methods, instance side
"protocol: ston-core" stonOn: stonWriter "We only write out our id"
stonWriter writeObject: self listSingleton: self id asString
and class side
"protocol: ston-core" fromSton: stonReader ^ self fromId: stonReader parseListSingleton
The #fromId: methods retrieves an existing instance.
HTH,
Sven
Hi Sven, I do not want to keep all the KnowObjects in the memory. One of the goal is to export from an image and to load from another. The following does not work: | obj string| obj := STONTestKnownObject new description: 'something else'; yourself. string := STON toStringPretty: obj. STONTestKnownObject resetKnownObjects. self assert: (STON fromString: string) description = 'something else' What is the simple may to customize only one or two variable(s)? -- Cyril Ferlicot https://ferlicot.fr http://www.synectique.eu 2 rue Jacques Prévert 01, 59650 Villeneuve d'ascq France