New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsonrpc-lite

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonrpc-lite

Parse and Serialize JSON-RPC2 messages in node.js or browser.

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
933K
increased by348.57%
Maintainers
1
Weekly downloads
 
Created

What is jsonrpc-lite?

The jsonrpc-lite package is a lightweight implementation of the JSON-RPC 2.0 protocol. It allows developers to easily create and parse JSON-RPC 2.0 requests and responses, making it suitable for building APIs and services that communicate using this protocol.

What are jsonrpc-lite's main functionalities?

Creating JSON-RPC Requests

This feature allows you to create a JSON-RPC request object. The code sample demonstrates how to create a request for a method named 'add' with parameters 'a' and 'b'.

const jsonrpc = require('jsonrpc-lite');
const request = jsonrpc.request(1, 'add', { a: 5, b: 3 });
console.log(request);

Parsing JSON-RPC Messages

This feature allows you to parse a JSON-RPC message string into a JSON-RPC object. The code sample shows how to parse a JSON-RPC request message.

const jsonrpc = require('jsonrpc-lite');
const message = '{"jsonrpc":"2.0","method":"add","params":{"a":5,"b":3},"id":1}';
const parsed = jsonrpc.parse(message);
console.log(parsed);

Creating JSON-RPC Responses

This feature allows you to create a JSON-RPC response object. The code sample demonstrates how to create a successful response with a result.

const jsonrpc = require('jsonrpc-lite');
const response = jsonrpc.success(1, { result: 8 });
console.log(response);

Creating JSON-RPC Errors

This feature allows you to create a JSON-RPC error response. The code sample shows how to create an error response for a method not found.

const jsonrpc = require('jsonrpc-lite');
const error = jsonrpc.error(1, jsonrpc.JsonRpcError.methodNotFound());
console.log(error);

Other packages similar to jsonrpc-lite

Keywords

FAQs

Package last updated on 02 Sep 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc