Package jsonrpc2 provides an implementation of JSON-RPC 2.0, for the Go programming-language (golang).
Find a file
2026-01-25 07:19:54 -08:00
error.go is-empty 2026-01-20 06:34:00 -08:00
go.mod uint2048 2026-01-22 13:44:41 -08:00
go.sum uint2048 2026-01-22 13:44:41 -08:00
id.go docs 2026-01-25 05:47:27 -08:00
id_marshaljson_test.go id 2026-01-24 09:22:11 -08:00
id_string_test.go id 2026-01-24 09:27:55 -08:00
id_unmarshaljson_test.go id 2026-01-24 09:34:17 -08:00
LICENSE initial commits 2026-01-20 05:27:43 -08:00
notification.go json tags 2026-01-20 06:01:56 -08:00
notification_marshaljson_test.go tests 2026-01-20 19:03:30 -08:00
notification_unmarshaljson_test.go notification 2026-01-22 14:12:25 -08:00
null.go id 2026-01-24 09:34:17 -08:00
params.go params 2026-01-25 06:23:39 -08:00
README.md docs 2026-01-24 10:08:47 -08:00
request.go request 2026-01-25 07:19:54 -08:00
request_marshaljson_test.go params 2026-01-25 06:17:16 -08:00
response.go id 2026-01-22 17:26:15 -08:00
response_marshaljson_test.go id 2026-01-22 17:26:15 -08:00

go-jsonrpc2

Package jsonrpc2 provides an implementation of JSON-RPC 2.0, for the Go programming-language (golang).

(The JSON-RPC 2.0 specification is available here: https://www.jsonrpc.org/specification )

From the JSON-RPC 2.0 specification:

JSON-RPC is a stateless, light-weight [client-server based] remote procedure call (RPC) protocol. […] It is transport agnostic in that the concepts can be used within the same process, over sockets, over http, or in many various message passing environments.

It is designed to be simple!

[…]

Since JSON-RPC utilizes JSON, it has the same type system [as JSON].

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-jsonrpc2

GoDoc

Example

An example JSON-RPC 2.0 request, send from the client to the server, looks like this:

{"jsonrpc": "2.0", "id": 1, "method": "subtract", "params": [42, 23]}

And, an example JSON-RPC 2.0 response, send from the server to the client, looks like this:

{"jsonrpc": "2.0", "id": 1, "result": 19}

(The "jsonrpc" is always set to "2.0".)

(Note that the value of the "id" field is the same in the request and the response.)

Using this package, the request can be represented in Go code as:

import "github.com/reiver/go-jsonrpc2"

// ...

request := jsonrpc2.Request{
	ID:     IDint64(1),
	Method: "subtract",
	Params: []int{42, 23},
}

And, the response can be represents in Go code as:

import "github.com/reiver/go-jsonrpc2"

// ...

response := jsonrpc2.Response{
	ID:     IDint64(1),
	Result: 19,
}

Import

To import package jsonrpc2 use import code like the following:

import "github.com/reiver/go-jsonrpc2"

Installation

To install package jsonrpc2 do the following:

GOPROXY=direct go get github.com/reiver/go-jsonrpc2

Author

Package jsonrpc2 was written by Charles Iliya Krempeaux