amnaredo / test

0 stars 0 forks source link

Long value not rendered correctly #251

Open amnaredo opened 3 years ago

amnaredo commented 3 years ago

https://github.com/lihaoyi/upickle/blob/a7238c05406f9e0767745b47e96cb31e166649d4/ujson/src/ujson/Renderer.scala#L118

According to this line, it is checked if the number could be fitted into an integer. But it does not work for long values that exceeds maximum value of integers. So for example, given a long value = 4031571442644776, ujson would output it as a double value like "4.031571442644776E15", that's incorrect.

A possible solution is to rewrite that toInt to toLong. ID: 268 Original Author: lilac

amnaredo commented 3 years ago

Seems like correct JSON to me

> JSON.parse( "4.031571442644776E15")
4031571442644776

> JSON.parse( "4.031571442644776E15") == 4031571442644776
true

Original Author: lihaoyi