{"id":17287415,"url":"https://github.com/adamslevy/jsonrpc2","last_synced_at":"2025-08-02T10:12:19.308Z","repository":{"id":53049281,"uuid":"138862735","full_name":"AdamSLevy/jsonrpc2","owner":"AdamSLevy","description":"Golang package for implementing a JSON RPC 2.0 server or client.","archived":false,"fork":false,"pushed_at":"2023-07-06T08:16:47.000Z","size":127,"stargazers_count":11,"open_issues_count":2,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T11:07:23.652Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/AdamSLevy.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":"2018-06-27T09:52:00.000Z","updated_at":"2024-06-22T10:50:26.000Z","dependencies_parsed_at":"2024-06-18T18:18:30.166Z","dependency_job_id":"396a33ec-7fe8-4073-9a6a-28ff5658643d","html_url":"https://github.com/AdamSLevy/jsonrpc2","commit_stats":{"total_commits":95,"total_committers":4,"mean_commits":23.75,"dds":0.03157894736842104,"last_synced_commit":"2d689058f1f877bc1f6029311d08b09040bfc0c5"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdamSLevy%2Fjsonrpc2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdamSLevy%2Fjsonrpc2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdamSLevy%2Fjsonrpc2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdamSLevy%2Fjsonrpc2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdamSLevy","download_url":"https://codeload.github.com/AdamSLevy/jsonrpc2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248868768,"owners_count":21174758,"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-10-15T10:02:18.463Z","updated_at":"2025-04-14T11:07:29.277Z","avatar_url":"https://github.com/AdamSLevy.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# github.com/AdamSLevy/jsonrpc2/v14\n[![GoDoc](https://godoc.org/github.com/AdamSLevy/jsonrpc2?status.svg)](https://godoc.org/github.com/AdamSLevy/jsonrpc2)\n[![Go Report Card](https://goreportcard.com/badge/github.com/AdamSLevy/jsonrpc2)](https://goreportcard.com/report/github.com/AdamSLevy/jsonrpc2)\n[![Coverage Status](https://coveralls.io/repos/github/AdamSLevy/jsonrpc2/badge.svg?branch=master)](https://coveralls.io/github/AdamSLevy/jsonrpc2?branch=master)\n[![Build Status](https://travis-ci.org/AdamSLevy/jsonrpc2.svg?branch=master)](https://travis-ci.org/AdamSLevy/jsonrpc2)\n\nPackage jsonrpc2 is a complete and strictly conforming implementation of the\nJSON-RPC 2.0 protocol for both clients and servers.\n\nThe full specification can be found at https://www.jsonrpc.org.\n\n## Clients\n\nThe simplest way to make a JSON-RPC 2.0 request is to use the provided\nClient.Request.\n```golang\n     var c jsonrpc2.Client\n     params := []float64{1, 2, 3}\n     var result int\n     err := c.Request(nil, \"http://localhost:8080\", \"sum\", params, \u0026result)\n     if _, ok := err.(jsonrpc2.Error); ok {\n     \t// received Error Request\n     }\n     if err != nil {\n     \t// some JSON marshaling or network error\n     }\n     fmt.Printf(\"The sum of %v is %v.\\n\", params, result)\n```\n\nFor clients that do not wish to use the provided Client, the Request and\nResponse types can be used directly.\n\n```golang\n     req, _ := json.Marshal(jsonrpc2.Request{Method: \"subtract\",\n       \tParams: []int{5, 1},\n       \tID:     0,\n       })\n       httpRes, _ := http.Post(\"www.example.com\", \"application/json\",\n       \tbytes.NewReader(req))\n       resBytes, _ := ioutil.ReadAll(httpRes.Body)\n       res := jsonrpc2.Response{Result: \u0026MyCustomResultType{}, ID: new(int)}\n       json.Unmarshal(respBytes, \u0026res)\n```\n\n## Servers\n\nServers define their own MethodFuncs and associate them with a name in a\nMethodMap that is passed to HTTPRequestHandler() to return a corresponding\nhttp.HandlerFunc. See HTTPRequestHandler for more details.\n```golang\n     func getUser(ctx context.Context, params json.RawMessage) interface{} {\n     \tvar u User\n     \tif err := json.Unmarshal(params, \u0026u); err != nil {\n     \t\treturn jsonrpc2.InvalidParams(err)\n     \t}\n     \tconn, err := mydbpkg.GetDBConn()\n     \tif err != nil {\n     \t\t// The handler will recover, print debug info if enabled, and\n     \t\t// return an Internal Error to the client.\n     \t\tpanic(err)\n     \t}\n     \tif err := u.Select(conn); err != nil {\n     \t\treturn jsonrpc2.NewError(-30000, \"user not found\", u.ID)\n     \t}\n     \treturn u\n     }\n\n     func StartServer() {\n     \tmethods := jsonrpc2.MethodMap{\"version\": versionMethod}\n     \thttp.ListenAndServe(\":8080\", jsonrpc2.HTTPRequestHandler(methods))\n     }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamslevy%2Fjsonrpc2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamslevy%2Fjsonrpc2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamslevy%2Fjsonrpc2/lists"}