gildas-lormeau / JSONVue

Fork of JSONView for Chromium-based browsers
https://chrome.google.com/webstore/detail/chklaanhfefbnpoihckbnefhakgolnmc
Other
1.59k stars 615 forks source link

Floating point numbers incorrectly converted to integers #40

Closed paulschreiber closed 2 years ago

paulschreiber commented 10 years ago

Floating point numbers ending in .0 are incorrectly converted to integers:

Example:

{
  "4": {
    "name": "Hello",
    "vorb": 14.0
  },
  "5": {
    "name": "Goodbye",
    "vorb": 15
  },
  "6": {
    "name": "Tacos",
    "vorb": 15.1
 }
}

jsonview

lsloan commented 8 years ago

The Firefox version of JSONView 1.1.1 does not have this problem.

https://addons.mozilla.org/en-us/firefox/addon/jsonview/

gildas-lormeau commented 2 years ago

The data displayed in the browser is a JavaScript object, so it's converted to a Number.

lsloan commented 2 years ago

There's no disagreement that the values are numbers. The problem is that a floating point "14.0" is being displayed as an integer "14".

gildas-lormeau commented 2 years ago

The extension relies on JSON.parse to parse the JSON string and convert it to a JavaScript object, that's why the value is an integer. JSON.parse("14.0") returns 14 and that's the expected behavior.

paulschreiber commented 2 years ago

That's definitely not what users are expecting the behaviour to be.

gildas-lormeau commented 2 years ago

Then, they should use another extension maybe. The goal of this one is to display JSON strings as JavaScript objects.