Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

vimagination.zapto.org/jsonrpc

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vimagination.zapto.org/jsonrpc

Go Modules
Version
v1.3.1
Version published
Created
Source

jsonrpc

CI Go Reference Go Report Card

-- import "vimagination.zapto.org/jsonrpc"

Package jsonrpc implements simple JSON RPC client/server message handling systems.

Highlights

  • JSONRPC client that can send request, or wait for server pushed messages.
  • JSONRPC server that can handle requests using a simple Handler interface, or push messages to the clients.
  • Works over any io.ReadWriter.

Usage

package main

import (
	"encoding/json"
	"fmt"
	"net"

	"vimagination.zapto.org/jsonrpc"
)


func Handler(method string, params json.RawMessage) (any, error) {
	if method == "welcome" {
		var name string

		if err := json.Unmarshal(params, &name); err != nil {
			return nil, err
		}

		return "Welcome, " + name, nil
	}

	return nil, fmt.Errorf("unknown method: %s", method)
}

func main() {
	server, client := net.Pipe()

	go jsonrpc.New(server, jsonrpc.HandlerFunc(handler)).Handle()

	var response string

	if err := jsonrpc.NewClient(client).RequestValue("welcome", "User", &response); err != nil {
		fmt.Println("Error: ", err)
	} else {
		fmt.Println(response)
	}

	// Output: Welcome, User
}

Documentation

Full API docs can be found at:

https://pkg.go.dev/vimagination.zapto.org/jsonrpc

FAQs

Package last updated on 23 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts