upickle icon indicating copy to clipboard operation
upickle copied to clipboard

Integers are not parsed correctly

Open polarker opened this issue 2 years ago • 3 comments

read[Int]("1.1") returns 1, instead of throwing an error

polarker avatar Mar 10 '22 11:03 polarker

@lihaoyi Is this a bug or a feature? 😅

polarker avatar Apr 01 '22 10:04 polarker

Haha good question. I don't actually know.

It seems the direction we're moving in is to be more forgiving on reads - e.g. https://github.com/com-lihaoyi/upickle/pull/385 allows us to read numeric strings as primitives as well - so it's not unreasonable that we would be forgiving to reading fractional integers as well.

Could go either way really

lihaoyi avatar Apr 21 '22 23:04 lihaoyi

Something like the configuration flag ACCEPT_FLOAT_AS_INT in Jackson could be nice.

If you think this issue is not relevant anymore, please feel free to close it. Thanks for the answer.

polarker avatar Apr 22 '22 07:04 polarker