Closed
Bug 1512939
Opened 6 years ago
Closed 6 years ago
firefox JSON content is rendering numbers wrongly
Categories
(DevTools :: JSON Viewer, defect)
Tracking
(Not tracked)
RESOLVED
DUPLICATE
of bug 1431808
People
(Reporter: giladhoch, Unassigned)
Details
Attachments
(1 file)
25.28 KB,
image/png
|
Details |
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0
Steps to reproduce:
used firefox to view JSON content returning from a webserver (play/netty).
Here's the curl (verbose) reply (replacing actual server address and API, due to proprietary software I cannot disclose):
$ curl -v http://some-internal-server:9000/some/api
* Trying 123.123.123.123...
* TCP_NODELAY set
* Connected to some-internal-server (123.123.123.123) port 9000 (#0)
> GET /some/api HTTP/1.1
> Host: some-internal-server:9000
> User-Agent: curl/7.61.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Vary: Origin
< Date: Mon, 10 Dec 2018 09:21:21 GMT
< Content-Type: application/json
< Content-Length: 295
<
* Connection #0 to host some-intenrnal-server left intact
{"quote":{"timestamp":1543971634344616313,"amount":1000000000000000},"mid":{"timestamp":1543971634344562300,"value":1326950000,"bid":1326930000,"ask":1326970000},"indications":[{"timestamp":1543971634344562300,"reading":{"value":50}},{"timestamp":1543971634344562300,"reading":{"value":15000}}]}
additional technical details:
firefox version (copied from about):
Firefox Quantum
63.0.3 (64-bit)
Mozilla Firefox for Ubuntu canonical-1.0
OS:
$ uname --all
Linux hochgi-tp 4.15.0-42-generic #45-Ubuntu SMP Thu Nov 15 19:32:57 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release --all
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
Actual results:
The numbers within the JSON were rendered wrongly (rounding problems perhaps?)
Though, it was correct on the "Raw Data" tab.
attaching a clipped screenshot of the above curl reply rendered in the JSON viewer.
note that e.g. the first timestamp ends with 200 on the viewer, but 313 in the cURL reply.
Expected results:
JSON viewer tab should show same output as raw data.
P.S. that's just an example, after I noticed the issue, I started seeing it almost anywhere in the API where nanoseconds timestamps are being used,
Updated•6 years ago
|
Component: Untriaged → JSON Viewer
Product: Firefox → DevTools
Comment 1•6 years ago
|
||
it's because the JSON data is mapped to ECMAScript's value while displaying it.
https://tc39.github.io/ecma262/#sec-terms-and-definitions-number-value
> 4.3.20 Number value
> primitive value corresponding to a double-precision 64-bit binary format IEEE 754-2008 value
ECMAScript uses a double-precision 64-bit binary format IEEE 754-2008 value for number,
and 1543971634344616313 s not representable with it.
JSON itself however doesn't specify about the semantics of the number,
http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
> JSON is agnostic about the semantics of numbers. In any programming language,
> there can be a variety of number types of various capacities and complements,
> fixed or floating, binary or decimal. That can make interchange between
> different programming languages difficult. JSON instead offers only the
> representation of numbers that humans use: a sequence of digits.
> All programming languages know how to make sense of digit sequences
> even if they disagree on internal representations.
> That is enough to allow interchange.
so I'm not yet sure if this is expected behavior for "JSON viewer"
Updated•6 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•