{"id":22878055,"url":"https://github.com/peelonet/peelo-json","last_synced_at":"2026-05-01T15:32:21.591Z","repository":{"id":265324773,"uuid":"895778198","full_name":"peelonet/peelo-json","owner":"peelonet","description":"Minimal JSON parser for C++","archived":false,"fork":false,"pushed_at":"2024-11-30T12:21:44.000Z","size":322,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T14:18:31.591Z","etag":null,"topics":["cpp-library","header-only","json","json-parser"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peelonet.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":"2024-11-28T22:14:42.000Z","updated_at":"2024-11-30T10:04:42.000Z","dependencies_parsed_at":"2025-02-06T20:22:32.991Z","dependency_job_id":"2ada1a93-9ca1-4e6c-9896-b5892253788d","html_url":"https://github.com/peelonet/peelo-json","commit_stats":null,"previous_names":["peelonet/peelo-json"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/peelonet/peelo-json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peelonet%2Fpeelo-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peelonet%2Fpeelo-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peelonet%2Fpeelo-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peelonet%2Fpeelo-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peelonet","download_url":"https://codeload.github.com/peelonet/peelo-json/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peelonet%2Fpeelo-json/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32503072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cpp-library","header-only","json","json-parser"],"created_at":"2024-12-13T16:17:44.454Z","updated_at":"2026-05-01T15:32:21.572Z","avatar_url":"https://github.com/peelonet.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# peelo-json\n\n![Build](https://github.com/peelonet/peelo-json/workflows/Build/badge.svg)\n\nI recently stumbled across an [Hacker News post] that announced an\n[alternative] to the widely used [nlohmann JSON] library for C++.\n\nIt gave me an idea to test how much work it would be to write a minimal [JSON]\nparser library for C++ and this is the result.\n\nI wanted to be as tiny as possible, not to include it's own UTF-8 decoder\n(bring your own) and not to throw exceptions but use result type instead.\n\n[Doxygen generated API documentation.][API]\n\n[Hacker News Post]: https://news.ycombinator.com/item?id=42132533\n[alternative]: https://github.com/jart/json.cpp\n[nlohmann JSON]: https://github.com/nlohmann/json/\n[JSON]: https://www.json.org\n[API]: https://peelonet.github.io/peelo-json/index.html\n\n## Dependencies\n\nThis library depends on another header only library called [peelo-result]. This\nshould be handled by [CMake].\n\n[peelo-result]: https://github.com/peelonet/peelo-result\n[CMake]: https://cmake.org\n\n## Usage\n\n### Parsing JSON\n\nYou can use `peelo::json::parse()` function to parse an Unicode string into\nJSON value.\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cpeelo/json.hpp\u003e\n\nint\nmain()\n{\n  const auto result = peelo::json::parse(U\"[1, 2, 3]\");\n\n  if (result)\n  {\n    if (peelo::json::type_of(*result) == peelo::json::type::array)\n    {\n      const auto array = peelo::json::as\u003cpeelo::json::array\u003e(*result);\n\n      std::cout \u003c\u003c \"Given input produced an array.\" \u003c\u003c std::endl;\n      std::cout \u003c\u003c \"It has \" \u003c\u003c array-\u003eelements().size() \u003c\u003c \" elements.\" \u003c\u003c std::endl;\n    }\n  } else {\n    std::cout \u003c\u003c \"Parsing error occurred: \" \u003c\u003c result.error().what() \u003c\u003c std::endl;\n  }\n}\n```\n\nIf you want specicially to parse an JSON object, you can use\n`peelo::json::parse_object()` function instead, which does not accept any\nother input than an object.\n\n### Formatting JSON\n\nTo format an JSON value returned by `peelo::json::parse()` function into an\nASCII string, you can use `peelo::json::format()` function.\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cpeelo/json.hpp\u003e\n\nint\nmain()\n{\n  if (const auto result = peelo::json::parse(U\"{\\\"foo\\\": \\\"bar\\\"}\"))\n  {\n    // This should output `{\"foo\":\"bar\"}` to standard output.\n    std::cout \u003c\u003c peelo::json::format(*value) \u003c\u003c std::endl;\n  }\n}\n```\n\n## TODO\n\n- Pretty print option for formatting JSON values.\n- `std::u32string` version of `format()` function.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeelonet%2Fpeelo-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeelonet%2Fpeelo-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeelonet%2Fpeelo-json/lists"}