Skip to content

Commit

Permalink
docs(typo): 2023-10-06-numbers-and-json.md
Browse files Browse the repository at this point in the history
  • Loading branch information
edm00se authored Oct 7, 2023
1 parent 297edd4 commit 1275176
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion content/posts/2023-10-06-numbers-and-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The short version is that numeric values in JSON strings need to be valid `float

### Why Is This a "Problem"?

As far as I can tell, the previously generated output was coming from a C based runtime that was generating the output with complete abandon for the ultimate JSON output itself. It succeeded in creating a numeric value that was parsable as either a `float` or `int`, making it technically correct, but mildly unhelpful and an annoyance for me, here _in the future_. JavaScript, JSON parse, and JSON stringify will each strip the `.0` specificity as its unnecessary for it as a numeric value, either as an `int` or `float`; it's just not needed and ny need to _display_ the value differently would likely require using [`.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed), because that's a function of display, not numeric value.
As far as I can tell, the previously generated output was coming from a C based runtime that was generating the output with complete abandon for the ultimate JSON output itself. It succeeded in creating a numeric value that was parsable as either a `float` or `int`, making it technically correct, but mildly unhelpful and an annoyance for me, here _in the future_. JavaScript, JSON parse, and JSON stringify will each strip the `.0` specificity as its unnecessary for it as a numeric value, either as an `int` or `float`; it's just not needed and any need to _display_ the value differently would likely require using [`.toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed), because that's a function of display, not numeric value.

![Futurama GIF showing a lawyer character stating "you are technically correct, the best kind of correcet"](./images/technically-correct.gif){.skinny}

Expand Down

0 comments on commit 1275176

Please sign in to comment.