Skip to content

fix #41: Large numbers serialized incorrectly - #42

Open
aleksanderd wants to merge 1 commit into
rxi:masterfrom
aleksanderd:master
Open

aleksanderd wants to merge 1 commit into
rxi:masterfrom
aleksanderd:master

Conversation

@aleksanderd

Copy link
Copy Markdown

No description provided.

@appgurueu

Copy link
Copy Markdown

Proper fix should be just using "%.17g".

@appgurueu

Copy link
Copy Markdown

Okay no, to support newer Lua versions and 64-bit integers, math.tointeger and %d should indeed be used; %g would have to be bumped to %.20g.

dtfiedler added a commit to dtfiedler/json.lua that referenced this pull request Nov 5, 2024
… decmials, return string value of integers

As mentioned in rxi#42 (comment) - Lua 5.3+ supports 64 bit integers. This change modifies the string encoding of numbers to align with those changes.
megvadulthangya added a commit to megvadulthangya/json.lua that referenced this pull request Oct 27, 2026
- Add Lua 5.5 compatibility (use table.unpack, math.tointeger)
- Rewrite encoder/decoder to use a rope for O(n) performance (rxi#46)
- Encode numbers with %.17g for lossless 64-bit float round-trip (rxi#42)
- Handle nil values in arrays by emitting null (rxi#52)
- Sort object keys for deterministic output (rxi#51)
- Support numeric table keys (rxi#43)
- Encode empty tables as [] by default, with force_object option (rxi#40)
- Add SPARSELIMIT for sparse array handling (rxi#28)
- Make number parsing locale-independent (rxi#20)
- Bump version to 0.2.0
- Update PKGBUILD for Lua 5.5 and new version
- Update README with supported versions and new options
- Add tests for nil arrays, sorted keys, empty tables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants