<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>170442</bug_id>
          
          <creation_ts>2017-04-04 01:49:25 -0700</creation_ts>
          <short_desc>Safari 10.1 JSON.parse returns incorrect object for numeric keys with decimal values</short_desc>
          <delta_ts>2017-04-26 11:49:32 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>Safari 10</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>macOS 10.12</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Martin Wiesinger">martin</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>commit-queue</cc>
    
    <cc>fpizlo</cc>
    
    <cc>gskachkov</cc>
    
    <cc>mark.lam</cc>
    
    <cc>saam</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>webkit</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1294007</commentid>
    <comment_count>0</comment_count>
    <who name="Martin Wiesinger">martin</who>
    <bug_when>2017-04-04 01:49:25 -0700</bug_when>
    <thetext>Additional invalid key/value pairs are added if the object contains numeric keys with a decimal number for the first two keys whose 1st decimal place isn&apos;t 0.

JSON.parse(&apos;{&quot;0&quot;:97.1,&quot;1000&quot;:96.5,&quot;2000&quot;:96.1,&quot;3000&quot;:97.4,&quot;4000&quot;:90.4}&apos;)
&gt; {0: 97.1, 1: NaN, 2: NaN, 1000: 96.5, 2000: 96.1, 3000: 97.4, 4000: 90.4}
If these are parseable to integers, this doesn&apos;t happen.
JSON.parse(&apos;{&quot;0&quot;:97.0,&quot;1000&quot;:96.0,&quot;2000&quot;:96.1,&quot;3000&quot;:97.4,&quot;4000&quot;:90.4}&apos;)
&gt; {0: 97, 1000: 96, 2000: 96.1, 3000: 97.4, 4000: 90.4}
Nor does the problem occur if we replace the numeric values with strings.
JSON.parse(&apos;{&quot;0&quot;:&quot;97.1&quot;,&quot;1000&quot;:&quot;96.5&quot;,&quot;2000&quot;:&quot;96.1&quot;,&quot;3000&quot;:&quot;97.4&quot;,&quot;4000&quot;:&quot;90.4&quot;}&apos;)
&gt; {0: &quot;97.1&quot;, 1000: &quot;96.5&quot;, 2000: &quot;96.1&quot;, 3000: &quot;97.4&quot;, 4000: &quot;90.4&quot;}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1294306</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2017-04-04 17:39:02 -0700</bug_when>
    <thetext>&lt;rdar://problems/31442949&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297115</commentid>
    <comment_count>2</comment_count>
    <who name="GSkachkov">gskachkov</who>
    <bug_when>2017-04-13 13:30:14 -0700</bug_when>
    <thetext>I can&apos;t reproduce this issue on current version of JSC, and it looks like duplicate of the fixed https://bugs.webkit.org/show_bug.cgi?id=164412</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297266</commentid>
    <comment_count>3</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2017-04-13 19:03:23 -0700</bug_when>
    <thetext>(In reply to GSkachkov from comment #2)
&gt; I can&apos;t reproduce this issue on current version of JSC, and it looks like
&gt; duplicate of the fixed https://bugs.webkit.org/show_bug.cgi?id=164412

Could you add a test for this to make sure we don&apos;t regress it in the future?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297348</commentid>
    <comment_count>4</comment_count>
      <attachid>307100</attachid>
    <who name="GSkachkov">gskachkov</who>
    <bug_when>2017-04-14 00:19:59 -0700</bug_when>
    <thetext>Created attachment 307100
Patch

Added additional tests</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297363</commentid>
    <comment_count>5</comment_count>
      <attachid>307100</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-04-14 01:28:56 -0700</bug_when>
    <thetext>Comment on attachment 307100
Patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297367</commentid>
    <comment_count>6</comment_count>
      <attachid>307100</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-04-14 02:08:55 -0700</bug_when>
    <thetext>Comment on attachment 307100
Patch

Clearing flags on attachment: 307100

Committed r215360: &lt;http://trac.webkit.org/changeset/215360&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297368</commentid>
    <comment_count>7</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-04-14 02:08:57 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1301605</commentid>
    <comment_count>8</comment_count>
    <who name="PiwEL">webkit</who>
    <bug_when>2017-04-26 09:01:27 -0700</bug_when>
    <thetext>It&apos;s the same problem even when the first key isn&apos;t 0, for JSON.parse and JSON.stringify.

JSON.stringify({ 8: 13.2, 111544: 132})
&gt; &quot;{\&quot;0\&quot;:null,\&quot;1\&quot;:null,\&quot;2\&quot;:null,\&quot;3\&quot;:null,\&quot;4\&quot;:null,\&quot;5\&quot;:null,\&quot;6\&quot;:null,\&quot;7\&quot;:null,\&quot;8\&quot;:13.2,\&quot;111544\&quot;:132}&quot;

If these are parseable to integers, this doesn&apos;t happen either.
JSON.stringify({ 8: 132, 111544: 132})
&gt; &quot;{\&quot;8\&quot;:132,\&quot;111544\&quot;:132}&quot;


And in the other way :
JSON.parse(&quot;{\&quot;8\&quot;:13.2,\&quot;111544\&quot;:132}&quot;);
&gt; {0: NaN, 1: NaN, 2: NaN, 3: NaN, 4: NaN, 5: NaN, 6: NaN, 7: NaN, 8: 13.2, 111544: 132}

I guess tests for theses cases should also be added, but I&apos;m sorry, I&apos;m new here and I don&apos;t know how to do it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1301710</commentid>
    <comment_count>9</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2017-04-26 11:49:32 -0700</bug_when>
    <thetext>(In reply to PiwEL from comment #8)
&gt; It&apos;s the same problem even when the first key isn&apos;t 0, for JSON.parse and
&gt; JSON.stringify.
&gt; 
&gt; JSON.stringify({ 8: 13.2, 111544: 132})
&gt; &gt; &quot;{\&quot;0\&quot;:null,\&quot;1\&quot;:null,\&quot;2\&quot;:null,\&quot;3\&quot;:null,\&quot;4\&quot;:null,\&quot;5\&quot;:null,\&quot;6\&quot;:null,\&quot;7\&quot;:null,\&quot;8\&quot;:13.2,\&quot;111544\&quot;:132}&quot;
&gt; 
&gt; If these are parseable to integers, this doesn&apos;t happen either.
&gt; JSON.stringify({ 8: 132, 111544: 132})
&gt; &gt; &quot;{\&quot;8\&quot;:132,\&quot;111544\&quot;:132}&quot;
&gt; 
&gt; 
&gt; And in the other way :
&gt; JSON.parse(&quot;{\&quot;8\&quot;:13.2,\&quot;111544\&quot;:132}&quot;);
&gt; &gt; {0: NaN, 1: NaN, 2: NaN, 3: NaN, 4: NaN, 5: NaN, 6: NaN, 7: NaN, 8: 13.2, 111544: 132}
&gt; 
&gt; I guess tests for theses cases should also be added, but I&apos;m sorry, I&apos;m new
&gt; here and I don&apos;t know how to do it.
Thanks for giving us this test case. We already added a test similar to this.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>307100</attachid>
            <date>2017-04-14 00:19:59 -0700</date>
            <delta_ts>2017-04-14 02:08:55 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-170442-20170414101957.patch</filename>
            <type>text/plain</type>
            <size>2910</size>
            <attacher name="GSkachkov">gskachkov</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjE1MzU3CmRpZmYgLS1naXQgYS9KU1Rlc3RzL0NoYW5nZUxv
ZyBiL0pTVGVzdHMvQ2hhbmdlTG9nCmluZGV4IDNkZWJlZTk2MmM2ZTI3ZDNmZWFkOTQ1YTgxYzA1
MmM4ZWQzNGFlNjUuLjMwOTQ4YWFjNjQ0YzIzMDEzZDlkY2U2YTRjZjdkZTA5Nzg3ODFlMzEgMTAw
NjQ0Ci0tLSBhL0pTVGVzdHMvQ2hhbmdlTG9nCisrKyBiL0pTVGVzdHMvQ2hhbmdlTG9nCkBAIC0x
LDMgKzEsMTIgQEAKKzIwMTctMDQtMTQgIE9sZWtzYW5kciBTa2FjaGtvdiAgPGdza2FjaGtvdkBn
bWFpbC5jb20+CisKKyAgICAgICAgU2FmYXJpIDEwLjEgSlNPTi5wYXJzZSByZXR1cm5zIGluY29y
cmVjdCBvYmplY3QgZm9yIG51bWVyaWMga2V5cyB3aXRoIGRlY2ltYWwgdmFsdWVzCisgICAgICAg
IGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0xNzA0NDIKKworICAgICAg
ICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICAqIHN0cmVzcy9vYmplY3Qt
bnVtYmVyLXByb3BlcnRpZXMuanM6CisKIDIwMTctMDQtMTMgIE1hcmsgTGFtICA8bWFyay5sYW1A
YXBwbGUuY29tPgogCiAgICAgICAgIFNob3VsZCB1c2UgZmx1c2hEaXJlY3QoKSB3aGVuIGZsdXNo
aW5nIHRoZSBzY29wZVJlZ2lzdGVyIGR1ZSB0byBuZWVkc1Njb3BlUmVnaXN0ZXIoKS4KZG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