[Pharo-users] Is it bad to have an order NeoJsonObject?

Norbert Hartl norbert at hartl.name
Thu Jun 7 02:16:11 EDT 2018



> Am 07.06.2018 um 07:29 schrieb Sven Van Caekenberghe <sven at stfx.eu>:
> 
> Tim,
> 
>> On 7 Jun 2018, at 01:37, Tim Mackinnon <tim at testit.works> wrote:
>> 
>> Hi - I’ve hit some Json where the outputted values (they are field names) are written out in a specific order - and the author hasn’t chosen to use an array to represent those fields in a specific order.
>> 
>> { ‘field1’ : { ….}, ‘field2’: { … } }
>> 
>> I think this is technically incorrect and should be:
>> 
>> { [ {‘field1’ : { ….}, ‘field2’: { … } ]}
>> 
>> Anyway - given what I’ve got, would it be a terrible idea to create my own version NeoJsonObject and just make it a subclass of OrderedDictionary?
>> 
>> I can’t see any issues - but then I might be kidding myself…
>> 
>> Tim
> 
> Yea, I think you could try making a NeoJSONOrderedObject as a subclass of OrderedDictionary, modelled after NeoJSONObject. Just remember it is implemented using DNU, which will surprise you at one point.
> 
Wouldn‘t be setting #mapClass: on the reader to OrderedDictionary not enough? Dictionary is the default anyway.

Norbert



More information about the Pharo-users mailing list