I always find it next to impossible to guess use cases for non-trivial features. So having those would help. Often YAGNI applies. Two possibilities: - Subtype Map and override toJSON - Use JSON.stringify() with a replacer
As Brandon Benvie mention, we could standardize on an array of pairs, but my (not very educated) guess would be that converting to objects makes more sense. On Oct 3, 2012, at 19:57 , Rick Waldron <[email protected]> wrote: > > > On Wed, Oct 3, 2012 at 1:35 PM, Axel Rauschmayer <[email protected]> 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... > > Rick > > > > > > -- > Dr. Axel Rauschmayer > [email protected] > > home: rauschma.de > twitter: twitter.com/rauschma > blog: 2ality.com > > -- Dr. Axel Rauschmayer [email protected] home: rauschma.de twitter: twitter.com/rauschma blog: 2ality.com
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

