{"id":21694645,"url":"https://github.com/badaix/jsonrpcpp","last_synced_at":"2025-08-20T16:30:58.716Z","repository":{"id":56263287,"uuid":"79714504","full_name":"badaix/jsonrpcpp","owner":"badaix","description":"C++ JSON-RPC 2.0 library","archived":false,"fork":false,"pushed_at":"2024-06-10T18:43:22.000Z","size":574,"stargazers_count":131,"open_issues_count":1,"forks_count":36,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-25T18:39:32.429Z","etag":null,"topics":["cpp11","json","json-rpc","json-rpc2","rpc"],"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/badaix.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":"2017-01-22T11:46:16.000Z","updated_at":"2024-11-22T06:14:45.000Z","dependencies_parsed_at":"2024-11-25T18:43:26.541Z","dependency_job_id":null,"html_url":"https://github.com/badaix/jsonrpcpp","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badaix%2Fjsonrpcpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badaix%2Fjsonrpcpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badaix%2Fjsonrpcpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/badaix%2Fjsonrpcpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/badaix","download_url":"https://codeload.github.com/badaix/jsonrpcpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230438185,"owners_count":18225870,"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":["cpp11","json","json-rpc","json-rpc2","rpc"],"created_at":"2024-11-25T18:31:24.386Z","updated_at":"2024-12-19T13:06:56.193Z","avatar_url":"https://github.com/badaix.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsonrpc++\n\nLeightweight C++ [JSON-RPC 2.0](http://www.jsonrpc.org/specification) library\n\n[![Github Releases](https://img.shields.io/github/release/badaix/jsonrpcpp.svg)](https://github.com/badaix/jsonrpcpp/releases)\n[![Build Status](https://travis-ci.org/badaix/jsonrpcpp.svg?branch=master)](https://travis-ci.org/badaix/jsonrpcpp)\n[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/badaix/jsonrpcpp.svg)](https://lgtm.com/projects/g/badaix/jsonrpcpp/context:cpp)  \n\n## What it is\n\njsonrpc++ parses and constructs [JSON-RPC 2.0](https://www.jsonrpc.org/specification) objects, like\n\n* [Request](http://www.jsonrpc.org/specification#request_object)\n  * [Notification](http://www.jsonrpc.org/specification#notification)\n  * [Parameter](http://www.jsonrpc.org/specification#parameter_structures)\n* [Response](http://www.jsonrpc.org/specification#response_object)\n  * [Error](http://www.jsonrpc.org/specification#error_object)\n* [Batch](http://www.jsonrpc.org/specification#batch)\n\n### Example: Parsing a request\n\n```c++\njsonrpcpp::entity_ptr entity = jsonrpcpp::Parser::do_parse(R\"({\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": {\"subtrahend\": 23, \"minuend\": 42}, \"id\": 3})\");\nif (entity-\u003eis_request())\n{\n    jsonrpcpp::request_ptr request = dynamic_pointer_cast\u003cjsonrpcpp::Request\u003e(entity);\n    if (request-\u003emethod() == \"subtract\")\n    {\n        int result = request-\u003eparams().get\u003cint\u003e(\"minuend\") - request-\u003eparams().get\u003cint\u003e(\"subtrahend\");\n        jsonrpcpp::Response response(*request, result);\n        cout \u003c\u003c \" Response: \" \u003c\u003c response.to_json().dump() \u003c\u003c \"\\n\";\n        //will print: {\"jsonrpc\": \"2.0\", \"result\": 19, \"id\": 3}\n    }\n    else\n        throw jsonrpcpp::MethodNotFoundException(*request);\n}\n```\n\n## What it not is\n\njsonrpc++ is completely transport agnostic, i.e. it doesn't care about transportation of the messages and there is no TCP client or server component shipped with this library.\n\nAs JSON backbone [JSON for Modern C++](https://nlohmann.github.io/json/) is used.\n\n## Some code example\n\n```c++\njsonrpcpp::entity_ptr entity =\n    jsonrpcpp::Parser::do_parse(R\"({\"jsonrpc\": \"2.0\", \"method\": \"subtract\", \"params\": {\"subtrahend\": 23, \"minuend\": 42}, \"id\": 3})\");\nif (entity \u0026\u0026 entity-\u003eis_request())\n{\n    jsonrpcpp::request_ptr request = dynamic_pointer_cast\u003cjsonrpcpp::Request\u003e(entity);\n    cout \u003c\u003c \" Request: \" \u003c\u003c request-\u003emethod() \u003c\u003c \", id: \" \u003c\u003c request-\u003eid() \u003c\u003c \", has params: \" \u003c\u003c !request-\u003eparams().is_null() \u003c\u003c \"\\n\";\n    if (request-\u003emethod() == \"subtract\")\n    {\n        int result;\n        if (request-\u003eparams().is_array())\n            result = request-\u003eparams().get\u003cint\u003e(0) - request-\u003eparams().get\u003cint\u003e(1);\n        else\n            result = request-\u003eparams().get\u003cint\u003e(\"minuend\") - request-\u003eparams().get\u003cint\u003e(\"subtrahend\");\n\n        jsonrpcpp::Response response(*request, result);\n        cout \u003c\u003c \" Response: \" \u003c\u003c response.to_json().dump() \u003c\u003c \"\\n\";\n    }\n    else if (request-\u003emethod() == \"sum\")\n    {\n        int result = 0;\n        for (const auto\u0026 summand : request-\u003eparams().param_array)\n            result += summand.get\u003cint\u003e();\n        jsonrpcpp::Response response(*request, result);\n        cout \u003c\u003c \" Response: \" \u003c\u003c response.to_json().dump() \u003c\u003c \"\\n\";\n    }\n    else\n    {\n        throw jsonrpcpp::MethodNotFoundException(*request);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadaix%2Fjsonrpcpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbadaix%2Fjsonrpcpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbadaix%2Fjsonrpcpp/lists"}