rxi / json.lua

A lightweight JSON library for Lua
MIT License
1.85k stars 365 forks source link

Large numbers serialized incorrectly #41

Open winseros opened 1 year ago

winseros commented 1 year ago

I have a lua object containing a large number:

local obj = {prop=1925036013156063406}

When the object is serialized, the JSON looks like:

{"prop":1.9250360131561e+18}

and can not be parsed by other JSON libraries on other programming languages.

The correct serializaion output would be:

{"prop":1925036013156063406}

aleksanderd commented 1 year ago

@winseros try this https://github.com/aleksanderd/json.lua/commit/15823a48b31befa5f623134f6d8c57a2f5a603f9

winseros commented 1 year ago

@aleksanderd it works fine. I'll use it for now. Thank you!

Vurv78 commented 1 year ago

Indeed it could be serialized differently, however that is valid JSON. Whatever other library you are parsing it from does not follow the spec.