> On 01 Jul 2016, at 00:56, Sven Van Caekenberghe <s...@stfx.eu> wrote: > > However, I also think that it might be possible to solve the ordering > requirement with a regular mapping, provided I make a little internal change > - I will investigate that and report back.
I committed the following (#bleedingEdge): === Name: Neo-JSON-Core-SvenVanCaekenberghe.34 Author: SvenVanCaekenberghe Time: 2 July 2016, 12:03:08.919979 am UUID: ded70581-c06f-4687-936c-11a029a39ba4 Ancestors: Neo-JSON-Core-SvenVanCaekenberghe.33 Use an OrderedDictionary instead of a regular Dictionary to store the properties inside a NeoJSONObjectMapping - this allows the user to control the order of properties while writing, if needed Add NeoJSONWriterTests>>#testPreservePropertyOrder === Name: Neo-JSON-Tests-SvenVanCaekenberghe.34 Author: SvenVanCaekenberghe Time: 2 July 2016, 12:03:30.417248 am UUID: 883b6ef1-e5fc-4d85-b86c-b21c1b5a3d6c Ancestors: Neo-JSON-Tests-SvenVanCaekenberghe.33 Use an OrderedDictionary instead of a regular Dictionary to store the properties inside a NeoJSONObjectMapping - this allows the user to control the order of properties while writing, if needed Add NeoJSONWriterTests>>#testPreservePropertyOrder === This allows for the following: NeoJSONWriterTests>>#testPreservePropertyOrder | writer testObject | (testObject := NeoJSONTestObject2 new) id: 123; width: 100; height: 50; data: 'test'. writer := [ :object | String streamContents: [ :stream | (NeoJSONWriter on: stream) for: NeoJSONTestObject2 do: [ :mapping | mapping mapInstVars: #(id width height data) ]; nextPut: object ] ]. self assert: (writer value: testObject) equals: '{"id":123,"width":100,"height":50,"data":"test"}'. For any permutation of the list of instance variables, each resulting in differently ordered JSON. This applies to all mapping techniques. Sven