@adt/json-rpc

Base JsonRpc classes. Represents all elements from JSON-RPC 2.0 specification http://www.jsonrpc.org/specification

Stats

StarsIssuesVersionUpdatedCreatedSize
@adt/json-rpc
300.0.1-SNAPSHOT.27a year ago4 years agoMinified + gzip package size for @adt/json-rpc in KB

Readme

JsonRpc npm version Build Status

Base JsonRpc classes. Represents all elements from JSON-RPC 2.0 specification http://www.jsonrpc.org/specification

Values that can be omitted, by default are set to undefined.

Specification says, that params in request can be ommited, but omitting property in object is not a good practice. Therefore, request and event object "params" property always exists, but can be set to value "undefined". When params property is undefined it will not be serialized.

Install

npm install @adt/json-rpc or yarn add @adt/json-rpc

Usage

import { JsoRpcEvent, JsonRpcRequest } from "@adt/json-rpc"

const byeEvent = JsonRpcEvent({
    method: "Bye",
    params:{
        name: "Joe"
    }
});

console.log(byeEvent.serialize());

const helloRequest = JsonRpcRequest({
    method: "Hello",
    params: {
        name: "Joe";
    }
});

console.log(helloRequest.serialize());

const helloRequestWithExplicitId = JsonRpcRequest({
    id: 1,
    method: "Hello",
    params: {
        name: "Joe";
    }
});

console.log(helloRequestWithExplicitId.serialize());

For more use cases please look at test specs.

Why i should use Json-RPC?

TODO :)

When i can use Json-RPC?

TODO :)

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.