dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.09k stars 1.56k forks source link

JsonDecoder and JsonCodec classes need more detail on how they handle numbers #46682

Open Hixie opened 3 years ago

Hixie commented 3 years ago

JSON and Dart-for-web do not distinguish between integers and doubles, but the Dart VM does. The JsonDecoder and JsonCodec API docs should explain how this is bridged (e.g. do all numbers become doubles?).

lrhn commented 3 years ago

In short: All JSON numbers are parsed as by num.parse. That goes for both Dart-for-web and VM, but on the web all integers are also doubles, so it's not as visible.