Open amnaredo opened 3 years ago
Seems reasonable. The quotes are because literal longs don't work in Javascript, which is half of uPickle's purpose in life. I don't mind making reading flexible.
Original Author: lihaoyi
Actually, we have a problem. If we want to read in literal numbers as Longs, we no longer can use JSON.parse
, and have to fall back to a much slower, manual parsing. That isn't great
Original Author: lihaoyi
@lihaoyi can you please explain why we would need to replace JSON.parse? The side effect of rounding the number is to be expected from the JS runtime, IMO this is not reason to discourage from using Long numbers. There are always other boxed solutions one can use. The result of this bug is that 3rd party serializers can't interop with upickle (because they optimistically transform Long to Number)
Original Author: romansky
I'm gonna close this. You can define your own Reader[Long]
and Writer[Long]
if you want this behavior. Corrupting everyone's data on Scala.js isn't really an option
Original Author: lihaoyi
It seems counterintuitive that a number that fits in an
Int
(and thus also aLong
) could be read as anInt
, but not aLong
unless the number is expressed as a string (i.e. quoted). I know that the uPickle document states thatLong
s are written as strings, but it seems that while reading it should work even with unquoted numbers as long as they fit. This will allow uPickle to consume data produced by other serializers (such as Jackson) that (by default) write numbers unquoted.ID: 66 Original Author: ramnivas