<br><br><div class="gmail_quote">On Wed, Oct 3, 2012 at 1:35 PM, Axel Rauschmayer <span dir="ltr"><<a href="mailto:axel@rauschma.de" target="_blank">axel@rauschma.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div style="word-wrap:break-word"><div class="im"><div><blockquote type="cite"><div class="gmail_quote"><div>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.</div>



</div></blockquote><br></div></div><div>The default should probably be to convert to an object whos keys are the results of applying String() to the maps 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:</div>

<div><br></div><div>1. Switch to pairs if the keys are not strings.</div><div>2. Allow a map to be configured which of the two representations should be used for toJSON.</div><div>3. Give toJSON a parameter whose default is to produce an object.</div>

<div><br></div><div>Given JSON.toStringify(), Im 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.</div><span class="HOEnZb"><font color="#888888"><br>

</font></span></div></blockquote><div><br></div><div>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.</div>

<div><br></div><div>Unless I'm looking at it the wrong way...</div><div><br></div><div>Rick</div><div><br></div><div><br></div><div><br></div><div><br></div><div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div style="word-wrap:break-word"><span class="HOEnZb"><font color="#888888"><div>
<span style="border-collapse:separate;border-spacing:0px"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:12px;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">

<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><span style="font-size:medium"><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">--</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">

Dr. Axel Rauschmayer</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><a href="mailto:axel@rauschma.de" target="_blank">axel@rauschma.de</a></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">

<br></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">home: <a href="http://rauschma.de" target="_blank">rauschma.de</a></div>

twitter: <a href="http://twitter.com/rauschma" target="_blank">twitter.com/rauschma</a></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">blog: <a href="http://2ality.com" target="_blank">2ality.com</a></div>

</span></div></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></div></span></span>
</div>
<br></font></span></div></blockquote></div><br>