Skip to content

maxgoren/libmgcjson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mgcjson

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.

installation

    make
    sudo make install
    sudo ldconfig

usage

    #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

About

Serialize/Deserialize JSON objects to and from strings in C

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors