ValkeyJSON is a C++ Valkey-Module that provides native JSON (JavaScript Object Notation) support for Valkey. The implementation complies with RFC7159 and ECMA-404 JSON data interchange standards. Users can natively store, query, and modify JSON data structures using the JSONPath query language. The query expressions support advanced capabilities including wildcard selections, filter expressions, array slices, union operations, and recursive searches.
ValkeyJSON leverages RapidJSON, a high-performance JSON parser and generator for C++, chosen for its small footprint and exceptional performance and memory efficiency. As a header-only library with no external dependencies, RapidJSON provides robust Unicode support while maintaining a compact memory profile of just 16 bytes per JSON value on most 32/64-bit machines.
# Build valkey-server (unstable) and run integration tests
./build.sh
The default valkey version is "unstable". To override it, do:
# Build valkey-server (8.0.0) and run integration tests
SERVER_VERSION=8.0.0 ./build.sh
Custom compiler flags can be passed to the build script via environment variable CFLAGS. For example:
CFLAGS="-O0 -Wno-unused-function" ./build.sh
mdkir build
cd build
cmake ..
make
The default valkey version is "unstable". To override it, do:
mdkir build
cd build
cmake .. -DVALKEY_VERSION=8.0.0
make
Custom compiler flags can be passed to cmake via variable CFLAGS. For example:
mdkir build
cd build
cmake .. -DCFLAGS="-O0 -Wno-unused-function"
make
cd build
make -j unit
make -j test
TEST_PATTERN=<test-function-or-file> make -j test
e.g.,
TEST_PATTERN=test_sanity make -j test
TEST_PATTERN=test_rdb.py make -j test
To test the module with a Valkey, you can load the module using any of the following ways:
1. Add the following to valkey.conf:
loadmodule /path/to/libjson.so
2. Start valkey-server:
valkey-server /path/to/valkey.conf
valkey-server --loadmodule /path/to/libjson.so
1. Connect to a running Valkey instance using valkey-cli
2. Execute Valkey command:
MODULE LOAD /path/to/libjson.so
JSON.ARRAPPEND
JSON.ARRINDEX
JSON.ARRINSERT
JSON.ARRLEN
JSON.ARRPOP
JSON.ARRTRIM
JSON.CLEAR
JSON.DEBUG
JSON.DEL
JSON.FORGET
JSON.GET
JSON.MGET
JSON.MSET (#16)
JSON.NUMINCRBY
JSON.NUMMULTBY
JSON.OBJLEN
JSON.OBJKEYS
JSON.RESP
JSON.SET
JSON.STRAPPEND
JSON.STRLEN
JSON.TOGGLE
JSON.TYPE