{"id":24819803,"url":"https://github.com/sebbekarlsson/libjson","last_synced_at":"2026-05-16T08:08:20.667Z","repository":{"id":81577993,"uuid":"202321734","full_name":"sebbekarlsson/libjson","owner":"sebbekarlsson","description":"Simple C implementation of JSON, parse JSON in C.","archived":false,"fork":false,"pushed_at":"2021-12-12T21:55:41.000Z","size":3826,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T18:01:14.208Z","etag":null,"topics":["clang","json","json-parser","lexer","parser","serialization"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebbekarlsson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-14T09:45:44.000Z","updated_at":"2022-03-26T03:01:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea7b8a38-1e4c-47ac-b640-92cb0e74db09","html_url":"https://github.com/sebbekarlsson/libjson","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebbekarlsson%2Flibjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebbekarlsson%2Flibjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebbekarlsson%2Flibjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebbekarlsson%2Flibjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebbekarlsson","download_url":"https://codeload.github.com/sebbekarlsson/libjson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245541907,"owners_count":20632404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clang","json","json-parser","lexer","parser","serialization"],"created_at":"2025-01-30T18:00:25.210Z","updated_at":"2026-05-16T08:08:15.647Z","avatar_url":"https://github.com/sebbekarlsson.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align='center'\u003e\u003cimg src='json-logo.png' width=\"400\"/\u003e\u003c/div\u003e\n\n# libjson\n\u003e Super fast JSON implementation in C, parse JSON in C with the speed of light.\n\n## Usage\n\u003e To parse json in C, here is an example.  \n\u003e Let's say we have a json file called **person.json**:\n```json\n{\n    \"age\": 32,\n    \"name\": \"John Doe\",\n    \"email\": \"doe@doecompany.com\"    \n}\n```\n\u003e ... and we want to parse it,\n\u003e and read the `name` field:\n```C\n#include \u003cjson/json_parser.h\u003e\n\n\nint main(int argc, char* argv[])\n{\n    // load the parser with the file\n    json_parser_T* parser = init_json_parser(init_json_lexer(read_file(\"shards/person.json\")));\n\n    // parse the file\n    json_ast_T* ast = json_parser_parse(parser);\n\n    // look for the key we are interested in\n    for (int i = 0; i \u003c ast-\u003ekey_value_list_size; i++)\n    {\n        json_ast_T* key_value = ast-\u003ekey_value_list_value[i];\n\n        if (strcmp(key_value-\u003ekey_value_key, \"name\") == 0)\n        {\n            // print it\n            printf(\"The name is: `%s`\\n\", key_value-\u003ekey_value_value-\u003estring_value);\n\n            // we were only interested in the name, so let's just break.\n            break;\n        }\n    }\n\n    // don't forget to free some memory.\n    json_parser_free(parser);\n    json_ast_free(ast);\n}\n```\n\u003e Compile your project with the `-ljson` flag:\n```bash\ngcc -ljson main.c\n```\n\n## Installing\n\u003e To install `libjson`, simply clown down the repo and run:\n```\nmake \u0026\u0026 sudo make install\n```\n\u003e Done! Now you can use it.\n\n## Speed\n\u003e The parser parses the [shards/boards.json](shards/boards.json) file in about\n\u003e `0.002` seconds:\n```bash\ntime ./a.out\n\nreal\t0m0.002s\nuser\t0m0.003s\nsys\t0m0.000s\n```\n\u003e Parsing the same file in `Nodejs` takes this much time:\n```bash\ntime node n.js \n\nreal\t0m0.412s\nuser\t0m0.402s\nsys\t0m0.012s\n```\n\u003e Parsing the same file in `Python` takes this much time:\n```bash\ntime python n.py \n\nreal\t0m0.016s\nuser\t0m0.004s\nsys\t0m0.012s\n```\n\u003e Conclusion: __My parser wins!__.\n\n## Valgrind output\n\u003e Here is the valgrind output after parsing [shards/boards.json](shards/boards.json):\n```\n==24912== HEAP SUMMARY:\n==24912==     in use at exit: 0 bytes in 0 blocks\n==24912==   total heap usage: 73,145 allocs, 73,145 frees, 118,651,826 bytes allocated\n==24912== \n==24912== All heap blocks were freed -- no leaks are possible\n==24912== \n==24912== For counts of detected and suppressed errors, rerun with: -v\n==24912== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)\n```\n\u003e No memory leaks, no errors! All good.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebbekarlsson%2Flibjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebbekarlsson%2Flibjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebbekarlsson%2Flibjson/lists"}