rxi/json.lua
rxi/json.lua has 2,199 GitHub stars and 372 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-06 23:08 UTC. Last push 2023-11-28.
A lightweight JSON library for Lua
What you can do
- Implemented in pure Lua: works with 5.1, 5.2, 5.3 and JIT
- Fast: generally outperforms other pure Lua JSON implementations (benchmark scripts)
- Tiny: around 280sloc, 9kb
- Proper error messages, eg: expected '}' or ',' at line 203 col 30
Measured star growth
- in 24h
- 0
- in 7 days
- Update delayed
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalA lightweight JSON library for Lua
Features
- Implemented in pure Lua: works with 5.1, 5.2, 5.3 and JIT
- Fast: generally outperforms other pure Lua JSON implementations (benchmark scripts)
- Tiny: around 280sloc, 9kb
- Proper error messages, eg:
expected '}' or ',' at line 203 col 30
Usage
The json.lua file should be dropped into an existing project and required by it:
json = require "json"
The library provides the following functions:
json.encode(value)
Returns a string representing value encoded in JSON.
json.encode({ 1, 2, 3, { x = 10 } }) -- Returns '[1,2,3,{"x":10}]'
json.decode(str)
Returns a value representing the decoded JSON string.
json.decode('[1,2,3,{"x":10}]') -- Returns { 1, 2, 3, { x = 10 } }
Notes
- Trying to encode values which are unrepresentable in JSON will never result in type conversion or other magic: sparse arrays, tables with mixed key types or invalid numbers (NaN, -inf, inf) will raise an error
nullvalues contained within an array or object are converted toniland are therefore lost upon decoding- Pretty encoding is not supported,
json.encode()only encodes to a compact format
License
This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
560,644 starspublic-apis/public-apis
A collective list of free APIs
496,896 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
439,727 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,110 stars