← Lessons

quiz vs the machine

Gold1300

Networking

The JSON RPC

A tiny text based remote call protocol over any transport.

4 min read · core · beat Gold to climb

A Minimal Protocol

JSON RPC is a lightweight remote procedure call protocol that uses plain JSON for both requests and responses. Its appeal is simplicity and that it works over almost any transport.

The Message Shape

A request is a small JSON object with a few fields.

  • A method name to call.
  • A params value with the arguments.
  • An id that ties a response back to its request.

A response carries either a result or an error, never both, plus the matching id.

Notifications And Batching

The protocol has two notable features.

  • A request with no id is a notification, expecting no reply.
  • Several requests can be sent as a batch in one array.

Because it is text and transport agnostic, JSON RPC is easy to debug and is used in places like editor language servers and some blockchain interfaces. The trade off versus binary frameworks is larger messages and no built in streaming, so it suits modest traffic rather than high volume internal calls.

Key idea

JSON RPC is a minimal text protocol where requests name a method with params and an id and responses carry a result or error, making it transport agnostic and easy to debug but heavier than binary frameworks.

Check yourself

Answer to earn rating on the learn ladder.

1. What ties a JSON RPC response to its request?

2. What is a JSON RPC notification?