{"id":35046707,"url":"https://github.com/castedo/jios","last_synced_at":"2026-04-27T14:03:56.630Z","repository":{"id":22196936,"uuid":"25529303","full_name":"castedo/jios","owner":"castedo","description":"JSON Input Output Streams","archived":false,"fork":false,"pushed_at":"2017-04-26T01:37:52.000Z","size":106,"stargazers_count":3,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-04-14T01:07:21.155Z","etag":null,"topics":["c-plus-plus","json","parsing","streams"],"latest_commit_sha":null,"homepage":null,"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/castedo.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":"2014-10-21T15:14:40.000Z","updated_at":"2019-08-16T11:14:49.000Z","dependencies_parsed_at":"2022-07-17T13:00:38.409Z","dependency_job_id":null,"html_url":"https://github.com/castedo/jios","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/castedo/jios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castedo%2Fjios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castedo%2Fjios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castedo%2Fjios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castedo%2Fjios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/castedo","download_url":"https://codeload.github.com/castedo/jios/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castedo%2Fjios/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32339296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"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":["c-plus-plus","json","parsing","streams"],"created_at":"2025-12-27T08:59:59.420Z","updated_at":"2026-04-27T14:03:56.622Z","avatar_url":"https://github.com/castedo.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"JIOS : JSON Input Output Streams\n================================\n\nSimilar to C++ streams, but the stream elements are structured JSON data rather\nthan characters.\n\nContents\n--------\n\n* [Features](#Features)\n* [Parsing Examples](#Parsing Examples)\n* [Printing Examples](#Printing Examples)\n* [Dependencies](#Dependencies)\n* [Other Libraries](#Other Libraries)\n\nFeatures\n--------\n\n### Incremental Streamed Parsing\n\nNot all parsing of JSON has to happen at once, but rather parsing can be\n**streamed** before all JSON is available. This is similar to many SAX parsers,\nbut with `jios` client code still calls `jios` and \"pulls\" data rather than\nbeing called like a SAX parser would.\n\n### Document Object Model (DOM) friendliness\n\nJSON objects and arrays are represented by distinct C++ types\nand can be \"walked\" and iterated in for loops like a DOM interface.\n\n### Non-blocking Parsing of Asynchronous Data Sources\n\n`jios` can be called assuming all data is available or the `expecting` method\ncan be called to check whether `jios` is still expecting more data. This can be\nused in asynchronous code to determine parsing should performed later when more\ndata is available.\n\n[Async Example](doc/async.md)\n\n### Parse Directly Into Strongly-types Data Structures\n\nSource back-end do not have to construct entire json objects in memory\nand instead data can read data incrementally into custom strongly types\nC++ objects.\n\nA template library (`express.hpp`) is included which makes it easy to\ndeclare the JSON object members to bind to C++ class members so that\nsuch C++ classes can immediately be read and written as JSON.\n\n[Expression Example](doc/express.md)\n\n### Interoperable with standard C++ streams\n\nThree ways `jios` interoperates with C++ streams:\n\n* included back-end source and sink and read and write with C++ streams.\n* C++ types and have insertion (\u003c\u003c) and extraction (\u003e\u003e) defined for C++ streams\n  automatically work with `jios`. This mechanism can be overloaded when C++\n  types should be represented as structures JSON rather than JSON strings.\n* The `jios` front-end provides syntactic sugar and semantics\n  that are like C++ streams.\n\n### Separate Independent Back-ends\n\nStreams are backed by source and sink back-ends which do not have to operate on\ntextual JSON.\n\n### Interoperability with Google Protocol Buffers \n\nC++ classes generated by Google Protocol Buffers are automatically\nreadable and writable to any `jios` sources and sinks.\n\n\nParsing Examples\n----------------\n```cpp\n  istringstream ss(\"1 \\\"two\\\" 3\");\n  int i, j;\n  string s;\n  json_in(ss) \u003e\u003e i \u003e\u003e s \u003e\u003e j;\n```\n\n\n### Use any type with the istream \u003e\u003e (extraction) operator defined\n\n```cpp\n  using namespace boost::posix_time;\n  istringstream ss(\"[\\\"00:01:03\\\", \\\"00:00:12\\\"]\");\n  time_duration t1, t2;\n  ijarray ija = json_in(ss).get().array();\n  ija \u003e\u003e t1 \u003e\u003e t2;\n  cout \u003c\u003c boolalpha \u003c\u003c bool(t1 == seconds(63)) \u003c\u003c ' '\n                    \u003c\u003c bool(t2 == seconds(12)) \u003c\u003c endl;\n```\noutputs\n```\n  true true\n```\n\n### Parse JSON arrays into standard containers\n\n```cpp\n  istringstream ss(\"[1, 2, 3]\");\n  list\u003cint\u003e many;\n  json_in(ss) \u003e\u003e many;\n  list\u003cint\u003e expect = {1, 2, 3};\n  cout \u003c\u003c boolalpha \u003c\u003c bool(many == expect) \u003c\u003c endl;\noutputs\n```\n  true\n```\n\n### Iterate on JSON streams and arrays\n\n```cpp\n  istringstream ss(\"1 2 3 4 5\");\n  int sum = 0;\n  for (ijvalue \u0026 v : json_in(ss)) {\n    int i;\n    if (v.read(i)) {\n      sum += i;\n    }\n  }\n  cout \u003c\u003c sum \u003c\u003c endl;\n```\noutputs\n```\n  15\n```\n\n### JSON arrays are parsed as a stream and accessible incrementally\n\n```cpp\n  stringstream ss;\n  int i = 0;\n  ss \u003c\u003c \"[\";\n  ijarray ija = json_in(ss).get().array();\n  ss \u003c\u003c \"1 \";\n  ija \u003e\u003e i;\n  cout \u003c\u003c i \u003c\u003c endl;\n  ss \u003c\u003c \", 2 \";\n  ija \u003e\u003e i;\n  cout \u003c\u003c i \u003c\u003c endl;\n  ss \u003c\u003c \"]\";\n  if (ija.at_end()) { cout \u003c\u003c \"Done!\" \u003c\u003c endl; }\n```\noutputs\n```\n  1\n  2\n  Done!\n```\n\n### Iterate by name value pair on JSON objects\n\n```cpp\n  stringstream ss;\n  ss \u003c\u003c R\"( { \"a\":1, \"b\":2, \"c\":3 } )\";\n  int sum = 0;\n  for (ijpair \u0026 nv : json_in(ss).get().object()) {\n    int i;\n    if (nv.read(i)) {\n      sum += i;\n    }\n  }\n  cout \u003c\u003c sum \u003c\u003c endl;\n```\noutputs\n```\n  6\n```\n\n\n### Parse JSON object as stream of name value pairs\n\n```cpp\n  stringstream ss;\n  ss \u003c\u003c R\"( { \"Joe\":35, \"Jane\":33 } )\";\n  string name1, name2;\n  int age1, age2;\n  ijobject ijo = json_in(ss).get().object();\n  ijo \u003e\u003e tie(name1, age1) \u003e\u003e tie(name2, age2);\n  cout \u003c\u003c name1 \u003c\u003c \" is \" \u003c\u003c age1 - age2 \u003c\u003c \" years older than \"\n       \u003c\u003c name2 \u003c\u003c endl;\n```\noutputs\n```\n  Joe is 2 years older than Jane \n```\n\n\nPrinting Examples\n-----------------\n\n```cpp\n  jios::json_out(std::cout, '\\n') \u003c\u003c 1 \u003c\u003c 2 \u003c\u003c \"three\";\n```\noutputs\n```\n  1\n  2\n  \"three\"\n```\n\nIn the rest of the examples assume\n\n```cpp\n  using namespace std;\n  using namespace jios;\n  ojstream jout = json_out(cout);\n```\n\n### JSON Arrays\n\n```cpp\n  ojarray oja = jout.put().array();\n  for (int i = 0; i \u003c 3; ++i) {\n    oja \u003c\u003c i;\n  }\n  oja \u003c\u003c endj;\n```\noutputs\n```\n  [0, 1, 2]\n```\n\n### JSON Objects\n\n```cpp\n  string b = \"BEE\";\n  jout.put().object() \u003c\u003c make_pair(\"one\", 1) \u003c\u003c tie(\"two\", b) \u003c\u003c endj;\n```\noutputs\n```\n  {\"one\":1, \"two\":\"BEE\"}\n```\n\n### Use any type with the ostream \u003c\u003c (insertion) operator defined\n\n```cpp\n  using namespace boost::posix_time;\n  jout.put().array() \u003c\u003c seconds(3) \u003c\u003c seconds(2) \u003c\u003c seconds(1) \u003c\u003c endj;\n```\noutputs\n```\n  [\"00:00:03\", \"00:00:02\", \"00:00:01\"]\n```\n\nEven use such types as JSON object keys.\n\n```cpp\n  using namespace boost::posix_time;\n  jout.put().object() \u003c\u003c make_pair(seconds(3), \"launch\")\n                      \u003c\u003c make_pair(seconds(7), \"explode\") \u003c\u003c endj;\n```\noutputs\n```\n  {\"00:00:03\":\"launch\", \"00:00:07\":\"explode\"}\n```\n\nDependencies\n------------\n\n* C++11\n* [boost](www.boost.org)\n* [JSON-C](https://github.com/json-c/json-c)\n* Google Protocol Buffers (optional)\n\nOther Libraries\n---------------\n\nThere are many C/C++ JSON libraries. www.json.org has a long list of such C and C++ libraries.\n\nA few worth mentioning are\n\n* JSON-C : the C library currently used by jios\n* JsonCpp : a C++ library I have used in the past\n* https://github.com/Loki-Astari/ThorsSerializer\n* https://github.com/rsms/jsont\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcastedo%2Fjios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcastedo%2Fjios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcastedo%2Fjios/lists"}