Re: [Pharo-bugtracker] OrderPreservingDictionary does not properly convert to json anymore

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-bugtracker] OrderPreservingDictionary does not properly convert to json anymore

Sven Van Caekenberghe-2
Hi Paul,

There are several issues here.

NeoJSON cannot know that OrderPreservingDictionary is in fact a Dictionary, since it inherits from Collection. For that to work you have to add copy over the method

neoJsonOn: neoJSONWriter
        neoJSONWriter writeMap: self

This will work for encoding, but when decoding you will get back normal Dictionaries (or the #mapClass that you set on your reader). JSON does not encode types.

Also, there are various implementations of ordered Dictionary out there in the wild. From Pharo 4 we have OrderedDictionary. NeoJSON cannot support them all, hence it supports none ;-)

STON does solve this problem.

Sven

> On 28 May 2015, at 09:55, Paul Wilke <[hidden email]> wrote:
>
> Hi,
> there is a bug when converting OrderPreservingDictionary's into a json
> string.
>
> NeoJSONWriter toString: (OrderPreservingDictionary new
> at: 'key' put: 'value';
> yourself).
> -->["value"]
>
> In Pharo 2 the answer was as expected: {"key":"value"}
>
>
>
> --
> View this message in context: http://forum.world.st/OrderPreservingDictionary-does-not-properly-convert-to-json-anymore-tp4829014.html
> Sent from the Pharo Issue Tracker mailing list archive at Nabble.com.
> _______________________________________________
> Pharo-bugtracker mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker