> Actually I do not think that the above is that bad ;-) It is too explicit for me and easy to forget to do. :)
> I guess you could add some extension methods to NeoJSONWriter, or subclass it - yourself. In the end, this is probably the most reasonable. And I can change some of the defaults too (like pretty printing & LF line ending). Thanks for the discussion! Peter On Wed, Jul 25, 2018 at 7:21 PM, PBKResearch <pe...@pbkresearch.co.uk> wrote: > Just as a comment to Henrik, NeoJSON will already preserve the order of an > OrderedDictionary. When working with Stef on the HTML scraping booklet, I > decided to find a way to preserve the order of the selected items, partly > for aesthetic reasons, but mainly to demonstrate that the output matched > the > problem specification. I switched the collection of the output items to an > OrderedDictionary, not knowing whether it would work, and it came out as > expected. Building an OrderedDictionary of just the required instvars would > solve both the OP's problems, though perhaps less elegantly. > > Peter Kenny > > -----Original Message----- > From: Pharo-users <pharo-users-boun...@lists.pharo.org> On Behalf Of Sven > Van Caekenberghe > Sent: 25 July 2018 17:49 > To: Any question about pharo is welcome <pharo-users@lists.pharo.org> > Subject: Re: [Pharo-users] NeoJSON sorting instance variables/properties > > > > > On 25 Jul 2018, at 17:54, Henrik-Nergaard <draag...@outlook.com> wrote: > > > > Hi Peter, > > > > This functionallity is already available in STON where it preserves > > the order when you use an OrderedDictionary. > > And was implemented for the usecase of dealing with fileout and > versioning. > > Perhaps the same could be added to NeoJson so that instead of some > > magic flag you provide an OrderedDictionary sorted as you would like > > and it would then preserve the order. > > You are right, using OrderedDictionaries would fix the order. > > But I don't think that is what he wants: to fix the order of arbitrary > objects being mapped. > > Even in STON the order of properties of objects is undefined (as it is in > JSON). > > > If you aim to use it to preserve metada for filetree then there is a > > patch for that which can be found at > > https://github.com/DraagrenKirneh/PharoUtilities/tree/master/FileTreeF > > ix > > > > Best regards, > > Henrik > > > > > > > > -- > > Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html > > > > > >