Skip to content

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.

License

Notifications You must be signed in to change notification settings

Fraunhofer-IIS/libjapi

Repository files navigation

libjapi

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.

Documentation

The documentation can be found here.

Packages

Prebuild packages for CentOS 7 can be downloaded from the latest package Action.

Features

  • Synchronous communication (request, response)
  • Asynchronous communication (register, push)
  • Multi-client support

Getting started

Prerequisites

Installation

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

Tests

The testsuite from googletest is used. To run tests, call

$ cd build
$ make run_test

Demo

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

References

Contributing

Pre-commit hooks

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.

Code Coverage

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.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •