{"id":13420101,"url":"https://github.com/jeaye/jeayeson","last_synced_at":"2026-02-25T10:05:04.876Z","repository":{"id":5443289,"uuid":"6636282","full_name":"jeaye/jeayeson","owner":"jeaye","description":"A very sane (header only) C++14 JSON library","archived":false,"fork":false,"pushed_at":"2017-01-02T02:00:43.000Z","size":246,"stargazers_count":133,"open_issues_count":2,"forks_count":23,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-01T22:24:55.895Z","etag":null,"topics":["c-plus-plus","json","modern-cpp","template"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeaye.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}},"created_at":"2012-11-11T07:01:56.000Z","updated_at":"2025-03-27T18:45:50.000Z","dependencies_parsed_at":"2022-09-25T03:01:20.193Z","dependency_job_id":null,"html_url":"https://github.com/jeaye/jeayeson","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jeaye/jeayeson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeaye%2Fjeayeson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeaye%2Fjeayeson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeaye%2Fjeayeson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeaye%2Fjeayeson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeaye","download_url":"https://codeload.github.com/jeaye/jeayeson/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeaye%2Fjeayeson/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29817098,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T05:36:42.804Z","status":"ssl_error","status_checked_at":"2026-02-25T05:36:31.934Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["c-plus-plus","json","modern-cpp","template"],"created_at":"2024-07-30T22:01:26.393Z","updated_at":"2026-02-25T10:05:04.849Z","avatar_url":"https://github.com/jeaye.png","language":"C++","funding_links":[],"categories":["TODO scan for Android support in followings","JSON","进程间通信"],"sub_categories":["Json"],"readme":"JeayeSON - a very sane C++14 JSON library [![Build Status](https://travis-ci.org/jeaye/jeayeson.svg?branch=master)](https://travis-ci.org/jeaye/jeayeson)\n---\n\nJeayeSON was designed out of frustration that there aren't many\ntemplate-based approaches to handling JSON in modern C++. Given a\nvery limited number of types (that JSON offers), functions\ncan be written in a generic manner to provide the most consistent\ninterface, no matter the type. JeayeSON is a non-validating JSON library;\nit expects valid JSON all of the time.\n\n  * Header only (easy to add to any project)\n  * Small, consistent C++ API\n  * Typesafe, C++14 interface\n  * Absolutely no macros needed nor used\n  * UTF-8 (with UTF-16 transcoding)\n  * Extensive test suite (using [jest](https://github.com/jeaye/jest), a \"sane and minimal C++14 unit test framework\")\n\nPractice\n----\nAssuming the JeayeSON headers are in your search path, simply\n```cpp\n#include \u003cjeayeson/jeayeson.hpp\u003e\n```\n**NOTE:** If you're on Windows and symbolic links don't work, use\n```cpp\n#include \u003cjeayeson/value.hpp\u003e\n```\nThis will give you access to the following types:\n```cpp\njson_value    /* variant type */\njson_map      /* string-\u003ejson_value map */\njson_array    /* contiguous array of json_values */\njson_null     /* json_value's default state */\njson_int      /* defaults to int64_t */\njson_float    /* defaults to double */\njson_file     /* aggregate type representing a filename */\njson_data     /* aggregate type representing json data as a string */\n```\n\nBuilding JSON\n----\nAssume we want to create this JSON:\n```json\n{\n  \"hello\": \"world\",\n  \"arr\":\n  [ 1.1, 2.2, 3.3 ],\n  \"person\":\n  {\n    \"name\": \"Tom\",\n    \"age\": 36,\n    \"weapon\": null\n  }\n}\n```\nWe can simply do:\n```cpp\njson_value val // json_value can be any json type; here, it's a json_map\n{\n  { \"hello\", \"world\" }, // nested pairs represent key/value\n  {\n    \"arr\",\n    { 1.1, 2.2, 3.3 } // arrays are easy\n  },\n  {\n    \"person\",\n    {\n      { \"name\", \"Tom\" },\n      { \"age\", 36 },\n      { \"weapon\", nullptr } // can also use json_null\n    }\n  }\n};\n```\nOr, if we wanted to build it piece by piece:\n```cpp\njson_map val; // explicitly make a map this time\n\nval[\"hello\"] = \"world\"; // simple assignments work on all compatible types\n\nval[\"arr\"] = { 1.1, 2.2, 3.3 }; // implicit array construction\n\njson_map person; // we'll build the person separately, too\nperson[\"name\"] = \"Tom\";\nperson[\"age\"] = 36;\nperson[\"weapon\"] = nullptr;\n\nval[\"person\"] = person; // now we can just put the person map into val\n\n// we can even dig into nested maps and arrays using op[]\nval[\"person\"][\"name\"] = \"Susan\";\n```\n\n### Reading a JSON string\n```cpp\nstd::string json; // Acquired/initialized elsewhere\njson_array arr{ json_data{ json } }; // simple aggregate for type-safety\n```\n### Reading a file\n```cpp\njson_map map{ json_file{ \"my_file.json\" } }; // simple aggregate for type-safety\n```\n### Writing JSON\n```cpp\n// maps, arrays, and values can all be used with streams\njson_map map{ json_file{ \"my_file.json\" } };\nstd::cout \u003c\u003c map \u003c\u003c std::endl;\n\n// you can also just write them to a string\nstd::string const json{ map.to_string() };\n```\n\nFeels like the C++ stdlib\n----\nYou'll find all the normal stdlib-like functions, including iterator support.\n```cpp\njson_array json;\njson.push_back(\"string\");\njson.push_back(3.14159);\njson.push_back(false);\n\nfor(auto const \u0026j : json) // has begin, end, cbegin, cend, etc\n{ std::cout \u003c\u003c j \u003c\u003c std::endl; }\n\n// works like an std::vector or std::map\njson.size();\njson.empty();\njson.clear();\njson.reserve(42);\n```\n\nType checking and casting\n----\n```cpp\njson_map json\n{\n  { \"boolean\", false },\n  { \"str\", \"...\" }\n};\n\n// check types with is\u003cT\u003e()\njson[\"boolean\"].is\u003cjson_value::type::boolean\u003e(); // true\njson[\"str\"].is\u003cjson_value::type::string\u003e(); // true\n\n// query the type enum\nauto const type(json[\"str\"].get_type());\n\n// cast with as\u003cT\u003e() to get the complete type\nauto const str(json[\"str\"].as\u003cjson_string\u003e());\n```\n\n### Installation\nThe `./configure` script must be used at least once to automagically generate `jeayeson/config.hpp` (see [Customization](https://github.com/jeaye/jeayeson#customization)). Since JeayeSON is a header-only library, simply copy over the contents of `include` to your project, or, better yet, add JeayeSON as a submodule and introduce `jeayeson/include` to your header search paths\n\nA full installation can also be achieved by using `./configure \u0026\u0026 make install`. See the `./configure` script for prefix options.\n\n### Dependencies\n\n* A C++14 compiler (GCC 5.x or Clang 3.8+ recommended)\n* Boost (1.55.0+ recommended)\n\nCustomization\n---\n**NOTE**: All configuration is easily done in `jeayeson/config.hpp`, which is generated when you run `./configure` (and is not overwritten subsequently -- delete it to reset).\n\nCustomization can be achieved by adjusting the types in the `jeayeson::config` struct template. A specialization is already provided, which contains the default types used by JeayeSON. Feel free to change the types to any other, still compatible, types.\n\nFor example, you may want the json integer type to be 32bit instead of the default 64bit. Or, you may want to use `std::unordered_map` instead of `std::map`.\n\n### Building tests\n**NOTE:** You don't actually have to build JeayeSON, since it's a header-only\nlibrary. This build process is only for the tests.\n\nIn the project directory, run:\n```bash\n$ ./configure \u0026\u0026 make\n\n# Depending on your compiler setup (gcc or clang, linux or osx, etc)\n# you may need to specify some extra flags. An example case:\n# (allows clang \u0026 libc++ to work on Arch Linux)\n$ CXX=clang++ CXX_FLAGS=-stdlib=libc++ LD_LIBS=-lc++abi make\n```\nOnce built, you can run the tests:\n```bash\n$ make test\n```\nThe tests (in `test/src` and `test/include`) can give more examples\non how to use JeayeSON.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeaye%2Fjeayeson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeaye%2Fjeayeson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeaye%2Fjeayeson/lists"}