{"id":13673816,"url":"https://github.com/Barenboim/json-parser","last_synced_at":"2025-04-28T13:31:51.859Z","repository":{"id":38345437,"uuid":"406865347","full_name":"Barenboim/json-parser","owner":"Barenboim","description":"JSON parser in standard C","archived":false,"fork":false,"pushed_at":"2025-04-27T09:06:27.000Z","size":74,"stargazers_count":683,"open_issues_count":3,"forks_count":84,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-27T09:29:18.770Z","etag":null,"topics":["c99","json"],"latest_commit_sha":null,"homepage":"https://github.com/sogou/workflow","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Barenboim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2021-09-15T17:28:05.000Z","updated_at":"2025-04-27T08:43:58.000Z","dependencies_parsed_at":"2023-12-09T20:30:54.128Z","dependency_job_id":"97b264f0-a1a7-4275-8d13-56d57c9c1def","html_url":"https://github.com/Barenboim/json-parser","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barenboim%2Fjson-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barenboim%2Fjson-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barenboim%2Fjson-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Barenboim%2Fjson-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Barenboim","download_url":"https://codeload.github.com/Barenboim/json-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251319757,"owners_count":21570451,"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":["c99","json"],"created_at":"2024-08-02T11:00:24.688Z","updated_at":"2025-04-28T13:31:46.803Z","avatar_url":"https://github.com/Barenboim.png","language":"C","readme":"[中文版说明](/README_cn.md)\n# Json Parser in Standard C (C99)\nThis json parser was created for the project of [C++ Workflow](https://github.com/sogou/workflow).  \n# Build tests\n~~~bash\n$ make\n~~~\n# Run tests\n### Parse and print json document:\n~~~bash\n$ ./parse_json \u003c xxx.json\n~~~\n### Test parsing speed:\n~~~bash\n$ time ./test_speed \u003crepeat times\u003e \u003c xxx.json\n~~~\n# Main Interfaces\n\n### JSON value related\n~~~c\n/* Parse JSON text and create a JSON value. Returns NULL on parsing\n   failures (Invalid JSON, nesting too deep, memory allocation failure).\n   @text: JSON text string */\njson_value_t *json_value_parse(const char *text);\n\n/* Destroy the JSON value\n   @val: JSON value. Typically created by the parsing function. */\nvoid json_value_destroy(json_value_t *val);\n\n/* Get JSON value's type\n     Return values:\n     JSON_VALUE_STRING: string\n     JSON_VALUE_NUMBER: number\n     JSON_VALUE_OBJECT: JSON object\n     JSON_VALUE_ARRAY: JSON array\n     JSON_VALUE_TRUE: true\n     JSON_VALUE_FALSE: false\n     JSON_VALUE_NULL: null\n   @val: JSON value */\nint json_value_type(const json_value_t *val);\n\n/* Obtain the JSON string. The function returns the string or\n   returns NULL if the type of @val is not JSON_VALUE_STRING.\n   @val: JSON value */\nconst char *json_value_string(const json_value_t *val);\n\n/* Obtain the JSON number. The function returns the number or\n   returns NAN if the type of @val is not JSON_VALUE_NUMBER.\n   @val: JSON value */\ndouble json_value_number(const json_value_t *val);\n\n/* Obtain JSON object. The function returns the JSON object or\n   returns NULL if the type of @val is not JSON_VALUE_OBJECT.\n   @val: JSON value\n   Note: The returned pointer to JSON object is not const.\n         You may extend the object using buiding functions. */\njson_object_t *json_value_object(const json_value_t *val);\n\n/* Obtain JSON arary. The function returns the JSON array or\n   returns NULL if the type of @val is not JSON_VALUE_ARRAY.\n   @val: JSON value\n   Note: The returned pointer to the JSON array is not const and\n         can been extended by using building functions. */\njson_array_t *json_value_array(const json_value_t *val);\n\n~~~\n### JSON object related\n~~~c\n/* Get the size of the JSON object.\n   @obj: JSON object */\nint json_object_size(const json_object_t *obj);\n\n/* Find the JSON value under the key @name. Returns NULL if @name\n   can not be found. The time complexity of this function is\n   O(log(n)), where n is the size of the JSON object.\n   @name: The key to find\n   @obj: JSON object\n   Note: The returned pointer to JSON value is const. */\nconst json_value_t *json_object_find(const char *name, const json_object_t *obj);\n\n/* Traversing the JSON object forward or backward\n   @name: Temporary (const char *) pointer for each key\n   @val: Temporary (const json_value_t *) pointer for each JSON value\n   @obj: JSON object\n   NOTE: These are not functions, but macros of looping. */\njson_object_for_each(name, val, obj)\njson_object_for_each_prev(name, val, obj)\n~~~\n\n### JSON array related\n~~~c\n/* Get the size of the JSON array.\n   @arr：JSON array */\nint json_array_size(const json_array_t *arr);\n\n/* Traversing the JSON array forward or backward\n   @val: Temporary (const json_value_t *) pointer for each JSON value\n   @arr: JSON array\n   NOTE: These are not functions, but macros of looping. */\njson_array_for_each(val, arr)\njson_array_for_each_prev(val, arr)\n~~~\n\n### Building JSON\nAll the following functions return NULL on failure of allocating memory.\n~~~c\n/* Create a JSON value.\n   @type: JSON value's type.\n   Note: Variable argument. Example:\n     v_str = json_value_create(JSON_VALUE_STRING, \"hello\");\n     v_num = json_value_create(JSON_VALUE_NUMBER, 3.14);\n     v_int = json_value_create(JSON_VALUE_NUMBER, (double)100);\n     v_obj = json_value_create(JSON_VALUE_OBJECT);\n     v_arr = json_value_create(JSON_VALUE_ARRAY);\n     v_true = json_value_create(JSON_VALUE_TRUE);\n   The returned value is not const and has to be destroyed. */\njson_value_t *json_value_create(int type, ...);\n\n/* Extend the JSON object. Returns the value that's added.\n   @obj: JSON object\n   @name: New member's name\n   @type: New member's value type or zero which means another JSON value\n   Note: Variable argument. Example:\n     v_num = json_object_append(obj, \"pi\", JSON_VALUE_NUMBER, 3.14);\n     v_obj = json_object_append(obj, \"user\", JSON_VALUE_OBJECT);\n     v_from_doc = json_object_append(obj, \"doc\", 0, json_value_parse(\"{\\\"data\\\" : [1, 2, 3]}\")); */\nconst json_value_t *json_object_append(json_object_t *obj, const char *name,\n                                       int type, ...);\n\n/* Remove a JSON value from a JSON object and return the value.\n   @val: JSON value to be removed.\n   @obj: JSON object\n   Note: The returned value is not const and need to be destroyed,\n         or appended to another JSON object or JSON array. */\njson_value_t *json_object_remove(const json_value_t *val,\n                                 json_object_t *obj);\n\n/* Extend the JSON array. Return the value that's added.\n   @arr: JSON array\n   @type: New member's value type or zero which means another JSON value\n   Note: Variable argument. Example:\n     v_str = json_array_append(arr, JSON_VALUE_STRING, \"hello\");\n     equal to:\n     v_str = json_array_append(arr, 0, json_value_create(JSON_VALUE_STRING, \"hello\")); */\nconst json_value_t *json_array_append(json_array_t *arr, int type, ...);\n\n/* Remove a JSON value from a JSON array and return the value.\n   @val: JSON value to be removed\n   @arr: JSON array\n   Note: The returned value is not const and need to be destroyed,\n         or appended to another JSON object or JSON array. */\njson_value_t *json_array_remove(const json_value_t *val,\n                                json_object_t *arr);\n\n~~~\n# A beautiful C++ wrapper\nhttps://github.com/wfrest/Json\n","funding_links":[],"categories":["Projects"],"sub_categories":["C"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBarenboim%2Fjson-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBarenboim%2Fjson-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBarenboim%2Fjson-parser/lists"}