A json module for LuaJIT 2.0/2.1 and Lua 5.1/5.2/5.3, based on the very fast RapidJSON C++ library.
See project homepage for more informations, bug report and feature request.
luarocks install rapidjson
or if you like to use your own version of RapidJSON, use:
luarocks install rapidjson RAPIDJSON_INCLUDE_DIRS=path/to/rapidjson/include/dir
local rapidjson = require('rapidjson')
rapidjson.encode()
rapidjson.decode()
rapidjson.load()
rapidjson.dump()
Lua Type | JSON type | Notes |
---|---|---|
rapidjson.null |
null |
|
true |
true |
|
false |
false |
|
string | string | |
table | array | when meta field __jsontype is 'array' or no __jsontype meta filed and table length > 0 or table length == 0 and empty_table_as_array option is specified |
table | object | when not an array, all non string keys and its values are ignored. |
number | number |
Clone or download source code, in the project root folder:
luarocks install dromozoa-utf8
luarocks install busted
luarocks make
busted
To compare speed of rapidjson and other json libraries:
lua performance/run.lua
See API reference.
- Pass all unit tests.
- Update version in rapidjson-..*-1.rockspec and update the name of the rockspec file.
- Tag source code with that version (v*..), and push.
luarocks upload rapidjson-*.*.*-1.rockspec
- Added Document SchemaDocument SchemaValidator to support JSON pointer and schema.
- Checks encoding error for float point numbers.
- RapidJSON compiling turn: use release config and turn SIMD on if supported.
- Fixes build and test errors introduced in 0.4.3.
- CMakeLists.txt supports command line defined
RAPIDJSON_INCLUDE_DIRS
to specified RapidJSON include directory. - Keeps only necessary RapidJSON header files and docs make the rock much smaller.
- Update RapidJSON to latest HEAD version.
- Fixes Windows dll.
- Checks circular reference when encoding tables.
- A table is encoded as json array if:
- have meta field
__jsontype
set to'array'
. - don't have meta filed
__jsontype
and length > 0.
- have meta field
- When table is encoded as json object, only string keys and its values are encoded.
- Integers are decoded to lua_Integer if it can be stored in lua_Integer.
- Follow integers are encoded as integers.
- Lua 5.3 integers.
- Integers stored in double and in between:
- [INT64_MIN..INT64_MAX] on 64 bit Lua or
- [INT32_MIN..INT32_MAX] in 32 bit Lua.
- CI scripts updated, thanks @ignacio
- Rename module to
rapidjson
. - Added
option.sort_keys
option torapidjson.encode()
andrapidjson.dump()
, and default value forsort_keys
isfalse
. - Added
rapidjson._NAME
("rapidjson"
) andrapidjson._VERSION
. rapidjson.object()
andrapidjson.array()
just set metatable field__jsontype
to'object'
and'array'
if passed table already have a metatable.- fixes dump return value of
false
rather thannil
.
- Initial release.