This is a simple C library for serializing/deserializing data from string to json and vice-versa.
to use, include mgc/json/json.h and compile with -lmgcjson after installing on your system.
make
sudo make install
sudo ldconfig
#include <mgc/json/json.h>
int main(int argc, char* argv[]) {
char* raw = "{ \"taco\" : \"tuesday\", \"toppings\": [ \"lettuce\", \"onions\", \"salsa\"], \"otra vez\": { \"tortilla\": \"con salsa\" } }";
JSON* as_json = toJSON(raw);
dump(ast);
char* as_str = JSONtoString(as_json);
JSON* member = getJSONElementByName(ast, "toppings");
JSON* element = getJSONArrayElementByIndex(member, 1);
printf("_[toppings][1]=%s\n", JSONtoString(element));
return 0;
}
compile with
gcc ex.c -o ex -lmgcjson