{"id":27867627,"url":"https://github.com/eteran/cpp-json","last_synced_at":"2025-05-04T22:51:21.340Z","repository":{"id":29078847,"uuid":"32606972","full_name":"eteran/cpp-json","owner":"eteran","description":"A fast \u0026 modern C++17 JSON library","archived":false,"fork":false,"pushed_at":"2024-02-13T16:28:42.000Z","size":233,"stargazers_count":52,"open_issues_count":1,"forks_count":9,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-05-01T13:38:49.715Z","etag":null,"topics":["c-plus-plus","cpp-json","json","json-parsing-library","unicode"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eteran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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}},"created_at":"2015-03-20T21:03:06.000Z","updated_at":"2023-11-09T05:39:03.000Z","dependencies_parsed_at":"2024-02-13T18:00:43.250Z","dependency_job_id":"17894511-cab2-4d79-85b4-240828d71296","html_url":"https://github.com/eteran/cpp-json","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eteran%2Fcpp-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eteran%2Fcpp-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eteran%2Fcpp-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eteran%2Fcpp-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eteran","download_url":"https://codeload.github.com/eteran/cpp-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252411813,"owners_count":21743604,"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":["c-plus-plus","cpp-json","json","json-parsing-library","unicode"],"created_at":"2025-05-04T22:51:20.665Z","updated_at":"2025-05-04T22:51:21.320Z","avatar_url":"https://github.com/eteran.png","language":"C++","readme":"**cpp-json is licensed under the GNU General Public License, version 2 or later.**\n\n**NOTE:** version [4.1](https://github.com/eteran/cpp-json/releases/tag/4.1) will be the last to not require C++17.\n\n**NOTE:** version [2.2](https://github.com/eteran/cpp-json/releases/tag/2.2) will be the last to not require C++11.\n\nThere are a few different JSON parsing libraries out there. But cpp-json aims to be the simplest to use while still being efficient by using modern c++ techniques. Additionally, this library is header only making it trivial to include in existing projects.\n\nCurrently, the only active item on the TODO list is to better support Unicode. Unicode is generally **well supported** in the form of `\\uXXXX` encoding, including code points which require surrogate pairs. The resulting `json::value` object will contain the string, encoded as UTF-8 since it is stored in a `std::string`. But there is no runtime detection or endian-ness detection based on the first few bytes (yet).\n\nOf course special consideration is needed when displaying these strings if they do in fact contain non ASCII characters.\n\nSo, for example,\n\n```json\n{ \"test1\": \"\\uD840\\uDC8A\" }\n```\n\nwill correctly parse and the object's \"test1\" member will have the byte sequence: `0xF0 0xA0 0x82 0x8A`\n\nHere is a simple example of the usage of this library:\n\n```c++\n#include \"cpp-json/json.h\"\n#include \u003cfstream\u003e\n#include \u003ciostream\u003e\n\nint main() {\n\t// open a file\n\tstd::ifstream file(\"test.json\");\n\n\t// load the file into a string\n\tstd::string contents = std::string{std::istreambuf_iterator\u003cchar\u003e(file), std::istreambuf_iterator\u003cchar\u003e()};\n\n\t// json::parse can take anything convertible to a string_view\n\tjson::value json = json::parse(contents);\n\n\t// you can access objects like associative array's easily\n\t// the result is a json::value\n\t// ... though in real code you may want to check the type first ;-)\n\tauto servlets = json[\"web-app\"][\"servlet\"];\n\n\t// when dealing with arrays, you can use iterators, indexing, or ranged-for\n\tfor(const json::value \u0026v : as_array(servlets)) {\n        \t// all basic types (numbers, strings, booleans) can be converted\n        \t// to a string\n        \tstd::cout \u003c\u003c to_string(v[\"servlet-name\"]) \u003c\u003c '\\n';\n\t}\n}\n```\n\nYou can also programmatically create `json::value` objects like this:\n\n```c++\nint main(int argc, char *argv[]) {\n\tauto arr = json::array {\n\t\t1,\n\t\t2,\n\t\t3,\n\t\t4,\n\t\t\"Testing 1 2 3\",\n\t\tjson::object{\n\t\t\t{ \"hello\", 1234 },\n\t\t\t{ \"world\", 5678 }\n\t\t}\n\t};\n\n\tstd::cout \u003c\u003c stringify(arr) \u003c\u003c std::endl;\n}\n```\n\nWhich of course results in a object representing the following JSON:\n\n```json\n[\n    1,\n    2,\n    3,\n    4,\n    \"Testing 1 2 3\",\n    {\n        \"hello\": 1234,\n        \"world\": 5678\n    }\n]\n```\n\nFinally, this library is very fast, when processing a 190 MB JSON file I randomly selected, parsing took no more than 18 seconds on my machine. For a Qt4 JSON parsing library, you can also checkout my other project: [QJson4](https://github.com/eteran/qjson4)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feteran%2Fcpp-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feteran%2Fcpp-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feteran%2Fcpp-json/lists"}