JConf is a feature-driven JSON parser for C/C++ applications.
JConf requires Make
and GCC
to compile the static library from source. To include JConf in your project:
- Run
make
from the root directory to build the library. - Copy
lib/libjconf.a
and theinclude
directory to your application. - Link the libjconf static library (e.g
gcc -I path/to/include/directory -L path/to/lib/directory -ljconf ...
)
- Includes well-defined data structures with their own APIs for user convenience.
- Does a single-pass for scanning and parsing using DFAs and states.
- Light-weight, portable, and fast.
- Easy to use.
The following is an example of a basic use case:
jToken *token, *value;
char* szStr;
jArgs args;
int number;
char* buffer = "{ \"Key\" : \"value\", \"Key2\" : 2, \"Key3\" : [3,4,5, {}] }";
token = jconf_json2c(buffer, strlen(buffer), &args);
// Verify the type of the JSON object.
if (token->type == JCONF_OBJECT)
{
// This gives the token that stores the value for the object at "Key".
value = jconf_get(token, "o", "Key");
szStr = (char*)value->data;
// szStr == "value"
// This gives the token that stores the array at index 1 for "Key3".
value = jconf_get(token, "oa", "Key3", 1);
number = atoi((char*)value->data);
// number == 4
}
jconf_free_token(token);
Run make test
to run the test suite.
Licensed under the MIT License