A pure Lua JSON library for encoding and decoding, optimized for speed and minimal footprint.
json.lua is a lightweight JSON library for Lua that provides encoding and decoding functions. It solves the need for a fast, minimal, and dependency-free way to handle JSON data in Lua applications across multiple Lua versions.
Lua developers who need to parse or generate JSON in their projects, especially those working with Lua 5.1, 5.2, 5.3, or LuaJIT and prioritizing performance and small code size.
Developers choose json.lua for its pure Lua implementation, which ensures compatibility without external dependencies, combined with its speed advantage over similar libraries and strict error handling for reliable JSON processing.
A lightweight JSON library for Lua
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Works with Lua 5.1, 5.2, 5.3, and LuaJIT without external dependencies, ensuring broad compatibility across Lua ecosystems.
Outperforms other pure Lua JSON libraries in benchmarks, as demonstrated by included benchmark scripts, making it efficient for performance-critical code.
At around 280 lines of code and 9kb, it is easy to integrate and minimal in footprint, ideal for resource-constrained projects.
Provides exact line and column numbers for parsing errors, such as 'expected '}' or ',' at line 203 col 30', aiding in quick debugging.
Raises errors for unrepresentable JSON values like sparse arrays or NaN, preventing silent data corruption and ensuring reliable encoding.
Only encodes to compact JSON format, lacking support for indented or human-readable output, which can be a drawback for debugging or configuration files.
Converts JSON null to Lua nil upon decoding, and since nil cannot be stored in tables, null values are lost, potentially compromising data integrity.
Errors on sparse arrays, tables with mixed key types, or invalid numbers like NaN, making it unsuitable for applications that need to handle non-standard or lenient JSON.