Skip to content

mushroomsir/jsonrpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsonrpc

Build Status Coverage Status License GoDoc

jsonrpc is an golang implementation just for parse and serialize JSON-RPC2 messages, it's easy to integration with your any application.

Inspired by https://github.com/teambition/jsonrpc-lite and JSON-RPC 2.0 specifications

Installation

go get github.com/mushroomsir/jsonrpc

API

jsonrpc.Request(id, method[, params])

Creates a JSON-RPC 2.0 message structures

  • id: {String|Int|nil}
  • method: {String}
  • params: {interface{}}, optional
	val, err := jsonrpc.Request(123, "update")
	{
    "jsonrpc": "2.0",
    "method": "update",
    "id": 123
    }

jsonrpc.Request2(method[, params])

Creates a JSON-RPC 2.0 message structures, the id is automatic generation by strconv.FormatInt(rand.Int63(), 10)

  • method: {String}
  • params: {interface{}}, optional
	val, err := jsonrpc.Request("update")
	{
    "jsonrpc": "2.0",
    "method": "update",
    "id": randnum
    }

jsonrpc.Notification(method[, params])

Creates a JSON-RPC 2.0 notification message structures

  • method: {String}
  • params: {interface{}}, optional
    val, err = jsonrpc.Notification("update")
    {
    "jsonrpc": "2.0",
    "method": "update"
    }