JSON-C Example
JSON-C Example So you want to parse JSON with C? Welcome aboard! First get json-c, configure, compile, and update your ld cache wget http://oss.metaparadigm.com/json-c/json-c-0.9.tar.gz tar xf json-c-0.9.tar.gz cd json-c-0.9 ./configure && make && sudo make install sudo ldconfig Now use one of the test files provided or this example: http://www.jroller.com/RickHigh/entry/json_parsing_with_c_simple cd .. vim json-example.c #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <string.h> #include "json.h" int main(int argc, char **argv) { struct json_object *new_obj; MC_SET_DEBUG(1); // I added some new lines... not in real program new_obj = json_tokener_parse("/* more difficult test case */ { \"glossary\": { \"title\": \"example glossary\", \"pageCount\": 100, \"GlossDiv\": { \"title\": \"S\", \"GlossList\": [ { \"ID...