hjson-py icon indicating copy to clipboard operation
hjson-py copied to clipboard

floats ending with '.0' turns into ints

Open jonathankarlsson opened this issue 3 years ago • 1 comments

This hjson: { test: 1.0 }

turns into {test: 1} after hjson.loads(). A type() call says it is an int. Maybe this is the wanted behavior? I just expected something else. "Normal" json returns a float.

jonathankarlsson avatar Mar 16 '21 15:03 jonathankarlsson

Not sure this is an issue. The serializer here removes the .0 https://hjson.github.io/try.html

However, it is inconsistent with json.tool.

/tmp
.venv ❯ echo '{"test": 1.0}' | python3 -m json.tool
{
    "test": 1.0
}
/tmp
.venv ❯ echo '{"test": 1.0}' | python3 -m hjson.tool
{
  test: 1
}

groodt avatar Aug 07 '22 11:08 groodt