Sets plus JSON
waldron.rick at gmail.com
Wed Oct 3 10:57:52 PDT 2012
On Wed, Oct 3, 2012 at 1:35 PM, Axel Rauschmayer <axel at rauschma.de> wrote:
> This also made me wonder about Maps, if the same use case were applied -
> toJSON simply wouldn't work when you have an object as a key.
> The default should probably be to convert to an object who’s keys are the
> results of applying String() to the map’s keys. Additionally, one could
> introduce a method toPairArray() that converts a Map into an array of pairs
> (2-element arrays) – that can be JSON-ified. The alternatives are:
> 1. Switch to pairs if the keys are not strings.
> 2. Allow a map to be configured which of the two representations should be
> used for toJSON.
> 3. Give toJSON a parameter whose default is to produce an object.
> Given JSON.toStringify(), I’m not sure that #2 is necessary and that #3 is
> useful. #1 might work, but seems like a big change in representation and it
> takes time to check all the keys.
My concern was actually about the references (for keys) that would be
broken, how would you get those back? There is no reasonably sane way that
doesn't involve magic scope memory tables and polluters.
Unless I'm looking at it the wrong way...
> Dr. Axel Rauschmayer
> axel at rauschma.de
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss