question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing an integer value when JSON contains a decimal point

See original GitHub issue
let result : int ParseResult = parseJSON "1.1"
let (Choice1Of2 value) = result
//val value : int = 1

I feel this is incorrect and should instead result in a failure. There’s possibly other similar edge cases like this one.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
wallymathieucommented, Jul 23, 2018

Seems like F# Data us fixing this as well: https://www.nuget.org/packages/FSharp.Data/3.0.0-beta4 :

(Breaking Change) Don’t silently convert decimals and floats to integers in JsonProvider.

0reactions
wallymathieucommented, Sep 25, 2018

I’ve added a PR that documents the behavior. Note that Fsharp.Data works the way you want.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to prevent removing decimal point when parsing JSON?
How to prevent removing decimal point when parsing JSON? · 2. JavaScript doesn't have distinct integer and floating point number types. · 1....
Read more >
Parsing Decimal values from JSON - Using Swift
I am trying to find a way to parse a number as Decimal without losing the number's precision. It seems that the JSON...
Read more >
Parsing JSON numbers and decimal point character
The number values in the returned JSON string are always supplied with a dot (".") for decimal point. It seems like JsonParser.
Read more >
Parsing JSON data for int and float - Power Platform Community
However, it often is not a whole number, and has decimal points, as it is currency. ... Change your Parse JSON Schema integer...
Read more >
Numeric types — Understanding JSON Schema 2020-12 ...
JSON does not have distinct types for integers and floating-point values. Therefore, the presence or absence of a decimal point is not enough...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found