{"id":25238638,"url":"https://github.com/rft0/lightjson","last_synced_at":"2026-02-16T16:32:21.898Z","repository":{"id":275763202,"uuid":"927111353","full_name":"rft0/lightjson","owner":"rft0","description":"Simple, Light Weight, Header Only, C++11 compliant JSON Library.","archived":false,"fork":false,"pushed_at":"2025-02-07T21:18:03.000Z","size":46,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T19:37:42.239Z","etag":null,"topics":["cpp","header-only","json","json-decoder","json-encoder","json-library","json-parser","json-serialization"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rft0.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}},"created_at":"2025-02-04T12:28:45.000Z","updated_at":"2025-02-20T17:54:20.000Z","dependencies_parsed_at":"2025-02-11T17:52:59.487Z","dependency_job_id":null,"html_url":"https://github.com/rft0/lightjson","commit_stats":null,"previous_names":["rft0/lightjson"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rft0/lightjson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rft0%2Flightjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rft0%2Flightjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rft0%2Flightjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rft0%2Flightjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rft0","download_url":"https://codeload.github.com/rft0/lightjson/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rft0%2Flightjson/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268448362,"owners_count":24252019,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"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","header-only","json","json-decoder","json-encoder","json-library","json-parser","json-serialization"],"created_at":"2025-02-11T17:52:51.647Z","updated_at":"2026-02-16T16:32:16.879Z","avatar_url":"https://github.com/rft0.png","language":"C++","readme":"# LightJSON\r\nLightJSON is a Simple, Light Weight, Header Only, C++11 compliant JSON Library. It is designed for projects which need a minimalistic JSON solution without the overhead of larger libraries.\r\n\r\n## Usage\r\n### Including Header\r\nJust include header file to use it.\r\n```c\r\n#include \"jspn.hpp\"\r\n```\r\nIf you only want to use reading contents of json without dumping / manipulaitng it you can disable those features. (which may help to reduce binary size)\r\n```c\r\n#define JSON_DISABLE_DUMPING\r\n#include \"jspn.hpp\"\r\n```\r\n### Parsing JSON\r\nFor starters you can pass either a raw pointer, std::string or a std::ifstream to parser.\r\n```cpp\r\nconst char* data = R\"(\"name\": \"John\", \"lastName\": \"Doe\", \"age\": 30, \"something\": [1, 2.5, {\"three\": \"four\"}])\";\r\nJSON json = JSONParser::parse(data)\r\n\r\n// or\r\n\r\nstd::ifstream f(\"test.json\");\r\nJSON json = JSONParser::parse(data)\r\n```\r\n### Reading Values\r\nReading simple fields.\r\n```cpp\r\nconst char* data = R\"(\"name\": \"John\", \"lastName\": \"Doe\", \"age\": 30, \"something\": [1, 2.5, {\"dummy\": \"dummyvalue\"}])\";\r\nJSON json = JSONParser::parse(data)\r\n\r\nstd::string name = json[\"name\"].as\u003cstd::string\u003e();       // John\r\nint age = json[\"age\"].as\u003cint\u003e();                         // 30\r\nint someFloat = json[\"something\"][1]                      // 2.5\r\nstd::string dummy = json[\"something\"][2][\"dummy\"]         // dummyvalue\r\n```\r\n\r\nReading arrays.\r\n```cpp\r\nconst char* data = R\"(\"intArray\": [1, 2, 3, 4, 5], \"complexArray\": [\"something\", 1, { \"dummy\": 2 }] )\";\r\nJSON json = JSONParser::parse(data);\r\n\r\n// Reading an array when all members are same type\r\nstd::vector\u003cint\u003e intArray = json[\"intArray\"].as\u003cstd::vector\u003cint\u003e\u003e(); // [1, 2, 3, 4, 5]\r\n\r\n// Reading an array when it contains members with different types.\r\nstd::vector\u003cJSON\u003e complexArray = json[\"complexArray\"].as\u003cstd::vector\u003cJSON\u003e\u003e();\r\ncomplexArray[0].as\u003cstd::string\u003e();     // something\r\ncomplexArray[1].as\u003cint\u003e();             // 1\r\ncomplexArray[2][\"dummy\"].as\u003cint\u003e();    // 2\r\n\r\n// or we can read value of field \"dummy\" like this.\r\nJSON anotherRoot = complexArray[2];\r\nanotherRoot[\"dummy\"].as\u003cint\u003e()         // 2\r\n```\r\n\r\n### Creating / Changing / Dumping Values\r\nDumping is disabled if `JSON_DISABLE_DUMPING` is defined.\r\n```c\r\nJSON root;\r\nroot[\"something\"] = \"another thing\";\r\nroot[\"exampleArray\"] = {1, 2, 3};\r\nroot[\"anotherObject][\"smt\"] = \"value\"; \r\n\r\n// Dumping json\r\nprintf(\"%s\", root.dump(4)); // (first argument means indentation space count, default: 4)\r\n\r\n// or we can dump json root directly with using overloaded \u003c\u003c operator.\r\nstd::cout \u003c\u003c root \u003c\u003c std::endl;\r\n\r\n// another way to create json from root with initializer lists\r\nJSON root = JSON::o({\r\n    {\"something\", \"another thing\"},\r\n    {\"exampleArray\", {1, 2, 3}},\r\n    {\"anotherObject\", { \"smt\", \"value\" }}\r\n});\r\n```\r\n\r\n\r\n\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frft0%2Flightjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frft0%2Flightjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frft0%2Flightjson/lists"}