[Webkit-unassigned] [Bug 170442] New: Safari 10.1 JSON.parse returns incorrect object for numeric keys with decimal values

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Apr 4 01:49:25 PDT 2017


https://bugs.webkit.org/show_bug.cgi?id=170442

            Bug ID: 170442
           Summary: Safari 10.1 JSON.parse returns incorrect object for
                    numeric keys with decimal values
           Product: WebKit
           Version: Safari 10
          Hardware: Macintosh
                OS: macOS 10.12
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: martin at cropster.com

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't 0.

JSON.parse('{"0":97.1,"1000":96.5,"2000":96.1,"3000":97.4,"4000":90.4}')
> {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't happen.
JSON.parse('{"0":97.0,"1000":96.0,"2000":96.1,"3000":97.4,"4000":90.4}')
> {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('{"0":"97.1","1000":"96.5","2000":"96.1","3000":"97.4","4000":"90.4"}')
> {0: "97.1", 1000: "96.5", 2000: "96.1", 3000: "97.4", 4000: "90.4"}

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170404/767f1815/attachment.html>


More information about the webkit-unassigned mailing list