libjapi is a universal JSON to C API library. It receives newline-delimited JSON (NDJSON) messages via TCP and calls registered C functions. A JSON response is returned for each request. Furthermore, it is also possible to create push services, which asynchronously push JSON messages to the clients subscribed to them.
The documentation can be found here.
Prebuild packages for CentOS 7 can be downloaded from the latest package Action.
- Synchronous communication (request, response)
- Asynchronous communication (register, push)
- Multi-client support
- json-c
- cmake version 3.6 for libjapi build
- cmake version 3.14 for libjapi test-framework build
Clone the git repository and it's submodules:
$ git clone --recurse-submodules [email protected]:Fraunhofer-IIS/libjapi.git
Create a build directory and call cmake in that directory.
$ mkdir build
$ cd build/
$ cmake ../
A Makefile is generated. Run 'make' to build the libjapi libraries.
$ make
A shared and a static library is built. Tests are built by default. They can be disabled using the command cmake -DLIBJAPI_ENABLE_TESTING=OFF ../
variable.
To run the internal tests run
$ ctest
The testsuite from googletest is used. To run tests, call
$ cd build
$ make run_test
You can clone the demo project, with examples for all features from the repository listed below:
$ git clone --recurse-submodules [email protected]:ks-ip-lib/software/libjapi-demo.git
- https://github.com/json-c/json-c
- http://json-c.github.io/json-c/
- https://en.wikipedia.org/wiki/JSON
- https://alan-mushi.github.io/2014/10/28/json-c-tutorial-part-1.html
When contributing to this project, automatic formatting of changes is strongly encouraged, so that formatting is getting more consistent over time.
To do so, ensure you have pre-commit
installed and do the following
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
This will run clang-format
on all changes you commit, gradually reformatting the code base to a more consistent state.
To test which part of the code is called by tests, use the coverage tool.
To do so, make sure you have lcov installed and do the following
$ mkdir build
$ cd build/
$ cmake -DCMAKE_BUILD_TYPE=Debug ../
$ make coverage
The result ist displayed in the console. Additionally a report is created at "build/coverage/index.html". You can also find it here.