{"id":23531549,"url":"https://github.com/zenmumbler/krystal","last_synced_at":"2025-07-21T11:36:46.667Z","repository":{"id":8925673,"uuid":"10654981","full_name":"zenmumbler/krystal","owner":"zenmumbler","description":"A mighty fine C++11 JSON reader","archived":false,"fork":false,"pushed_at":"2017-06-07T11:40:04.000Z","size":719,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-22T20:08:03.665Z","etag":null,"topics":["c-plus-plus","c-plus-plus-11","header-only","json","library","parser"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zenmumbler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-12T23:50:43.000Z","updated_at":"2020-10-19T00:47:03.000Z","dependencies_parsed_at":"2022-08-27T23:10:10.060Z","dependency_job_id":null,"html_url":"https://github.com/zenmumbler/krystal","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zenmumbler/krystal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenmumbler%2Fkrystal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenmumbler%2Fkrystal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenmumbler%2Fkrystal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenmumbler%2Fkrystal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenmumbler","download_url":"https://codeload.github.com/zenmumbler/krystal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenmumbler%2Fkrystal/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266292649,"owners_count":23906550,"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","c-plus-plus-11","header-only","json","library","parser"],"created_at":"2024-12-25T22:16:11.095Z","updated_at":"2025-07-21T11:36:46.617Z","avatar_url":"https://github.com/zenmumbler.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"krystal\n=======\n\nA C++11 JSON data reader with a simple but powerful API.\u003cbr\u003e\nBy Arthur Langereis ([@zenmumbler](http://twitter.com/zenmumbler/))\n\nDesign\n------\n\n- light-weight, clean codebase\n\t- a few classes and functions contained in a single `krystal` namespace\n\t- no macros or other global namespace pollution\n\t- depends on, and _only_ on the C++ standard library\n- C++11 only\n\t- uses new language and library features to keep design simple\n\t- move-only semantics for `value` instances to avoid costly copies\n- focus on ease of use\n\t- header-only framework\n\t- simple API with clear rules\n\t- integrated with language constructs (e.g. range for loop)\n\t- clear error messages in parser for syntax errors and in exceptions when using values\n\t- speed and memory usage limited by your std lib, but second only to rapidjson right now using clang \u0026 libc++\n- fully conformant to JSON spec\n\t- correctly parses entire jsonchecker test suite\n- UTF-8 only files and strings, [http://utf8everywhere.org/]()\n- number values are doubles, limiting exact int values to +/- 2^53\n- SAX and DOM style access\n\nExamples\n--------\n\nConvenient parse calls generate a document in a single call.\n\n\t// from a stream\n\tauto file = std::ifstream{\"game_data.json\"};\n\tauto doc = krystal::parseStream(file);\n\t\n\t// or from a string\n\tstd::string json { \"...json data...\" };\n\tauto doc = krystal::parseString(json);\n\n\t// you will always get a valid Value object\n\t// failed parse will yield a Null value, otherwise an Array or Object\n\tif (doc.isContainer())\n\t\t...; // succesfully parsed\n\nUse subscripting for array and object values.\n\n\tauto delay = doc[\"levels\"][0][\"zombie spawn delay\"].number();\n\tauto name = doc[\"levels\"][0][\"level name\"].string();\n\nIterate over arrays or objects with normal range for syntax. Each loop yields a pair of `krystal::Value`s.\nFor arrays, `first` is a number value with the index, for objects, `first` is the key string value.\n\n\tfor (auto kv : doc[\"levels\"]) {\n\t\tauto levelIndex = kv.first.numberAs\u003cint\u003e();\n\t\tauto\u0026 levelData = kv.second;\n\n\t\t...\n\t}\n\nUsage\n-----\n\nkrystal is a header-only library. Add the krystal directory to your include path and `#include`\nthe `krystal.hpp` umbrella header in your sources.\n\n\nStatus\n------\n\n/!\\ Does not compile against stdlibc++, because krystal exploits UB by using an incomplete type\nas the value of `vector` and `unordered_map`, the last of which stdlibc++ does not support\n(legitimately) See:\n[http://stackoverflow.com/questions/13089388/how-to-have-an-unordered-map-where-the-value-type-is-the-class-its-in]()\n\nI was not aware of this when I started work on krystal and am currently looking into how to remedy this,\nlikely by wrapping the values in a `unique_ptr` as those explicitly allow incomplete types.\n\nDoes work with Clang 3.2, 3.3 and 3.4 compilers with the libc++ standard library.\nWill not work on current (May 2014) MSVC compilers, even the CTP versions, because MSVC is not fully C++11 conformant yet.\n\nJSON output is not yet supported.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenmumbler%2Fkrystal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenmumbler%2Fkrystal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenmumbler%2Fkrystal/lists"}