{"id":18616674,"url":"https://github.com/sile/jsonlrpc","last_synced_at":"2026-02-03T16:31:25.765Z","repository":{"id":255460889,"uuid":"852603758","full_name":"sile/jsonlrpc","owner":"sile","description":"A JSON-RPC 2.0 library that streams JSON objects in JSON Lines format.","archived":false,"fork":false,"pushed_at":"2024-12-02T12:49:14.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T07:12:35.214Z","etag":null,"topics":["jsonl","jsonrpc","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/sile.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":"2024-09-05T05:13:09.000Z","updated_at":"2024-12-02T12:49:07.000Z","dependencies_parsed_at":"2024-11-02T10:20:44.905Z","dependency_job_id":"83734e6b-69d9-4fb0-bb6e-e2af3763c551","html_url":"https://github.com/sile/jsonlrpc","commit_stats":null,"previous_names":["sile/jsonlrpc"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Fjsonlrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Fjsonlrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Fjsonlrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Fjsonlrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sile","download_url":"https://codeload.github.com/sile/jsonlrpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248325266,"owners_count":21084900,"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":["jsonl","jsonrpc","rust"],"created_at":"2024-11-07T03:37:30.910Z","updated_at":"2026-02-03T16:31:25.758Z","avatar_url":"https://github.com/sile.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"jsonlrpc\n========\n\n[![jsonlrpc](https://img.shields.io/crates/v/jsonlrpc.svg)](https://crates.io/crates/jsonlrpc)\n[![Documentation](https://docs.rs/jsonlrpc/badge.svg)](https://docs.rs/jsonlrpc)\n[![Actions Status](https://github.com/sile/jsonlrpc/workflows/CI/badge.svg)](https://github.com/sile/jsonlrpc/actions)\n![License](https://img.shields.io/crates/l/jsonlrpc)\n\nA [JSON-RPC 2.0] library that streams JSON objects in [JSON Lines] format.\n\n[JSON-RPC 2.0]: https://www.jsonrpc.org/specification\n[JSON Lines]: https://jsonlines.org/\n\nUnsupported Features\n--------------------\n\n- Batch requests\n  - Batching complicates server and client implementations\n  - However, it provides little performance benefit with JSON Lines\n\nExamples\n--------\n\nRPC client:\n```rust\nuse std::net::TcpStream;\nuse jsonlrpc::{RpcClient, RequestId, RequestObject, ResponseObject, JsonRpcVersion};\n\n// Connect to a JSON-RPC server.\nlet server_addr = spawn_rpc_server_thread(); // See below\nlet socket = TcpStream::connect(server_addr).expect(\"failed to connect to server\");\nlet mut client = RpcClient::new(socket);\n\n// Send a request to the server.\nlet request = RequestObject {\n    jsonrpc: JsonRpcVersion::V2,\n    id: Some(RequestId::Number(1)),\n    method: \"foo\".to_string(),\n    params: None,\n};\nlet response = client.call(\u0026request).expect(\"failed to RPC call\");\n\n// Check the response.\nlet Some(ResponseObject::Ok { result, id, .. }) = response else {\n    panic!(\"expected ok response, got notification or err response\")\n};\nassert_eq!(id, RequestId::Number(1));\n```\n\nRPC server:\n```rust\nuse std::net::{SocketAddr, TcpListener};\nuse jsonlrpc::{JsonlStream, JsonRpcVersion, RequestObject, ResponseObject};\n\nfn spawn_server_thread() -\u003e SocketAddr {\n    let listener = TcpListener::bind(\"127.0.0.1:0\").expect(\"failed to bind to address\");\n    let addr = listener.local_addr().expect(\"failed to get local address\");\n\n    std::thread::spawn(move || {\n        for stream in listener.incoming() {\n            let stream = stream.expect(\"failed to accept incoming connection\");\n            let mut stream = JsonlStream::new(stream);\n            std::thread::spawn(move || {\n                let request: RequestObject = stream.read_value().expect(\"failed to read request\");\n                let response = ResponseObject::Ok {\n                    jsonrpc: JsonRpcVersion::V2,\n                    id: request.id.expect(\"expected request id\"),\n                    result: serde_json::Value::String(request.method),\n                };\n                stream.write_value(\u0026response).expect(\"failed to write response\");\n            });\n        }\n    });\n\n    addr\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Fjsonlrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsile%2Fjsonlrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Fjsonlrpc/lists"}