josdejong / josdejong/jsoneditor

Maintain formatting of float values like 1.0

Open
#711 11 comments 1 reaction 0 assignees View on GitHub
feature
Dominant language
JavaScript
Stars
12.3k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

A float value such as 1.0 should remain 1.0 and not be changed to 1 i.e. without the .0 on the end.

I know this has been raised a number of time before but they have been closed incorrectly.

The JSON specification for Number DOES treat integers and floats differently. See the spec - https://www.json.org/. You will notice that when a period is given there MUST be a following digit even if that digit is zero. This is how floats are distinguished from integers in JSON. It is incorrect to strip the ".0" from the end of a float and turn it into an integer.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.