{"id":13418791,"url":"https://github.com/hjiang/jsonxx","last_synced_at":"2025-12-17T10:08:00.114Z","repository":{"id":42078185,"uuid":"82999","full_name":"hjiang/jsonxx","owner":"hjiang","description":"A JSON parser in C++","archived":true,"fork":false,"pushed_at":"2021-02-21T06:34:45.000Z","size":149,"stargazers_count":535,"open_issues_count":15,"forks_count":172,"subscribers_count":37,"default_branch":"master","last_synced_at":"2024-07-31T22:44:03.883Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hjiang.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":"2008-12-01T07:55:25.000Z","updated_at":"2024-06-23T12:30:12.000Z","dependencies_parsed_at":"2022-09-21T14:28:59.122Z","dependency_job_id":null,"html_url":"https://github.com/hjiang/jsonxx","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjiang%2Fjsonxx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjiang%2Fjsonxx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjiang%2Fjsonxx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjiang%2Fjsonxx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hjiang","download_url":"https://codeload.github.com/hjiang/jsonxx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243685503,"owners_count":20330980,"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":[],"created_at":"2024-07-30T22:01:07.136Z","updated_at":"2025-12-17T10:07:59.796Z","avatar_url":"https://github.com/hjiang.png","language":"C++","readme":"# JSON++\n\n[![Build Status](https://travis-ci.org/hjiang/jsonxx.svg?branch=master)](https://travis-ci.org/hjiang/jsonxx)\n\n## Introduction\n\nJSON++ is a light-weight JSON parser, writer and reader written in C++.\nJSON++ can also convert JSON documents into lossless XML documents.\n\n## Contributors\n\n* http://github.com/hjiang\n* http://github.com/elanthis\n* http://github.com/r-lyeh\n\nIf you've made substantial contribution, please add your link here. \n\n## Why another JSON parser?\n\nPerhaps because web service clients are usually written in dynamic languages these days, none of the existing C++ JSON parsers fitted my needs very well, so I wrote one that I used in another project. My goals for JSON++ were:\n\n* Efficient in both memory and speed.\n* No third party dependencies. JSON++ only depends on the standard C++ library.\n* Cross platform.\n* Robust.\n* Small and convenient API. Most of the time, you only need to call one function and two function templates.\n* Easy to integrate. JSON++ only has one source file and one header file. Just compile the source file and link with your program.\n* Able to construct documents dynamically.\n* JSON writer: write documents in JSON format.\n\nOther contributors have sinced added more functionalities:\n\n* XML writer: convert documents to JSONx format. See http://goo.gl/I3cxs for details.\n* XML writer: convert documents to JXML format. See https://github.com/r-lyeh/JXML for details.\n* XML writer: convert documents to JXMLex format. See https://github.com/r-lyeh/JXMLex for details.\n* XML writer: convert documents to tagged XML format. See https://github.com/hjiang/jsonxx/issues/12 for details.\n\n## Compiler version\n\nYou need a modern C++ compiler. For older compilers, please try [legacy branch](https://github.com/hjiang/jsonxx/tree/legacy).\n\n## Configuration\n\n### Strict/permissive parsing\n\nJSONxx can parse JSON documents both in strict or permissive mode.\n\nWhen `jsonxx::Settings::Parser` is set to `Strict`, JSONxx parser will accept:\n* Fully conformant JSON documents *only*.\n\nWhen `jsonxx::Settings::Parser` is set to `Permissive`, JSONxx parser will accept:\n* Fully conformant JSON documents\n* Ending commas in arrays and objects: `{ \"array\": [0,1,2,], }`\n* Single quoted strings: `['hello', \"world\"]`\n* C++ style comments: `{ \"width\": 320, \"height\": 240 } //Picture details`\n\nDefault value is `Permissive`.\n\nWhen `jsonxx::Settings::UnquotedKeys` is set to `Enabled`, JSONxx parser will accept:\n* Unquoted keys: `{name: \"world\"}`\n\nDefault value is `Disabled`.\n\n### Assertions\n\nJSONxx uses internally `JSONXX_ASSERT(...)` macro that works both in debug and release mode. Set `jsonxx::Settings::Assertions` value to `Disabled` to disable assertions.\n\nDefault value is `Enabled`.\n\n## Usage\n\nThe following snippets are from one of the unit tests. They are quite self-descriptive.\n\n~~~C++\nusing namespace std;\nusing namespace jsonxx;\n\nstring teststr(\n        \"{\"\n        \"  \\\"foo\\\" : 1,\"\n        \"  \\\"bar\\\" : false,\"\n        \"  \\\"person\\\" : {\\\"name\\\" : \\\"GWB\\\", \\\"age\\\" : 60,},\"\n        \"  \\\"data\\\": [\\\"abcd\\\", 42],\"\n        \"}\"\n);\n\n// Parse string or stream\nObject o;\nassert(o.parse(teststr));\n\n// Validation. Checking for JSON types and values as well\nassert(1 == o.get\u003cNumber\u003e(\"foo\"));\nassert(o.has\u003cBoolean\u003e(\"bar\"));\nassert(o.has\u003cObject\u003e(\"person\"));\nassert(o.get\u003cObject\u003e(\"person\").has\u003cNumber\u003e(\"age\"));\nassert(!o.get\u003cObject\u003e(\"person\").has\u003cBoolean\u003e(\"old\"));\nassert(o.get\u003cObject\u003e(\"person\").get\u003cBoolean\u003e(\"old\", false));\nassert(o.has\u003cArray\u003e(\"data\"));\nassert(o.get\u003cArray\u003e(\"data\").get\u003cNumber\u003e(1) == 42);\nassert(o.get\u003cArray\u003e(\"data\").get\u003cString\u003e(0) == \"abcd\");\nassert(o.get\u003cArray\u003e(\"data\").get\u003cString\u003e(2, \"hello\") == \"hello\");\nassert(!o.has\u003cNumber\u003e(\"data\"));\ncout \u003c\u003c o.json() \u003c\u003c endl;                     // JSON output\ncout \u003c\u003c o.xml(JSONx) \u003c\u003c endl;                 // JSON to XML conversion (JSONx subtype)\ncout \u003c\u003c o.xml(JXML) \u003c\u003c endl;                  // JSON to XML conversion (JXML subtype)\ncout \u003c\u003c o.xml(JXMLex) \u003c\u003c endl;                // JSON to XML conversion (JXMLex subtype)\n~~~\n\n~~~C++\n// Generate JSON document dynamically\nusing namespace std;\nusing namespace jsonxx;\nArray a;\na \u003c\u003c 123;\na \u003c\u003c \"hello world\";\na \u003c\u003c 3.1415;\na \u003c\u003c 99.95f;\na \u003c\u003c 'h';\na \u003c\u003c Object(\"key\", \"value\");\nObject o;\no \u003c\u003c \"key1\" \u003c\u003c \"value\";\no \u003c\u003c \"key2\" \u003c\u003c 123;\no \u003c\u003c \"key3\" \u003c\u003c a;\ncout \u003c\u003c o.json() \u003c\u003c endl;\n~~~\n\n## To do\n\n* Custom JSON comments (C style /**/) when permissive parsing is enabled.\n","funding_links":[],"categories":["TODO scan for Android support in followings","JSON","进程间通信"],"sub_categories":["Json"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhjiang%2Fjsonxx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhjiang%2Fjsonxx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhjiang%2Fjsonxx/lists"}