Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ tanto Public

Tanto is a lightweight JSON parser and generator library written in C. It provides a simple interface for working with JSON data, allowing developers to easily parse JSON strings into C structures and create JSON output programmatically.

License

Notifications You must be signed in to change notification settings

msoodb/tanto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json parser and creator library in C, under development, not ready to use!

tanto.h

Using tanto

To use tanto you can include tanto.h header file.

#include "tanto.h"

typedef in tanto.h

TJSON_t *json;

example usage

TJSON_t *json = NULL;
TANTO_INIT(&json);


TJSON_t *server = tanto_create_node(TANTO_JSON_OBJECT, "server", NULL);
tanto_push(&json, server);

TJSON_t *path = tanto_create_node(TANTO_JSON_OBJECT_FIELD, "path", "http://www.gnu.org/licenses/");
tanto_push(&json, path);


TJSON_t *parser = tanto_create_node(TANTO_JSON_OBJECT_FIELD, "parser", "tanto");
TJSON_t *library = tanto_create_node(TANTO_JSON_OBJECT, "library", NULL);
TJSON_t *lex = tanto_create_node(TANTO_JSON_OBJECT_FIELD, "lex", "lexer");	
tanto_push(&json, parser);
tanto_push(&server, library);
tanto_push(&server, lex);

TJSON_t *usage = tanto_create_node(TANTO_JSON_OBJECT_FIELD ,"usage", "example.c");
TJSON_t *tests = tanto_create_node(TANTO_JSON_OBJECT_FIELD ,"tests", "test.c");	
tanto_push(&library, usage);	
tanto_push(&library, tests);


TJSON_t *color = tanto_create_node(TANTO_JSON_OBJECT_FIELD, "color", "red");
tanto_push(&json, color);

TJSON_t *main = tanto_create_node(TANTO_JSON_OBJECT_FIELD ,"main", "main.c");	
tanto_push(&json, main);


TJSON_t *functions = tanto_create_node(TANTO_JSON_ARRAY, "functions", NULL);
tanto_push(&json, functions);
TJSON_t *pop = tanto_create_node(TANTO_JSON_OBJECT_FIELD ,"pop", NULL);	
tanto_push(&functions, pop);
TJSON_t *push = tanto_create_node(TANTO_JSON_OBJECT_FIELD ,"push", NULL);	
tanto_push(&functions, push);

tanto_write_file("../json/example2-output.json", json);

make examples

$ make example
$ ./example1
$ ./example2

About

Tanto is a lightweight JSON parser and generator library written in C. It provides a simple interface for working with JSON data, allowing developers to easily parse JSON strings into C structures and create JSON output programmatically.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •