jsonrpc: JSON-RPC 2.0 types and type classes for Haskell

[ library, mpl, network, web ] [ Propose Tags ] [ Report a vulnerability ]

A lightweight implementation of the JSON-RPC 2.0 protocol types for Haskell with Aeson serialisation. Provides the core request, response, notification, and error types along with type classes for deriving JSON-RPC method dispatch via DerivingVia.

Implements the specification at https://www.jsonrpc.org/specification.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.2.0.0
Change log CHANGELOG.md
Dependencies aeson (>=2.1 && <2.3), base (>=4.18 && <4.22), text (>=2.0 && <2.2) [details]
Tested with ghc ==9.12.2
License MPL-2.0
Copyright (c) 2026 DPella AB
Author DPella AB
Maintainer matti@dpella.io, lobo@dpella.io
Uploaded by tritlo at 2026-02-16T13:38:54Z
Category Web, Network
Home page https://github.com/DPella/jsonrpc
Bug tracker https://github.com/DPella/jsonrpc/issues
Source repo head: git clone https://github.com/DPella/jsonrpc.git
Distributions
Reverse Dependencies 1 direct, 1 indirect [details]
Downloads 1 total (1 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-02-16 [all 1 reports]

Readme for jsonrpc-0.2.0.0

[back to package description]

jsonrpc

A lightweight Haskell implementation of JSON-RPC 2.0 protocol types with Aeson serialisation.

Features

  • Core message types: requests, responses, notifications, and errors
  • IsJSONRPCRequest / IsJSONRPCNotification type classes for automatic method dispatch via DerivingVia
  • Standard error codes from the specification
  • Spec-compliant JSON encoding (optional params, error data field, etc.)

Quick start

{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE TypeFamilies #-}

import JSONRPC
import Data.Aeson (FromJSON, ToJSON)
import GHC.Generics (Generic)

-- Define your request type
data PingRequest = PingRequest
    { id :: RequestId
    , params :: Maybe ()
    }
    deriving stock (Show, Eq, Generic)
    deriving (ToJSON, FromJSON) via ViaJSONRPCRequest PingRequest

instance IsJSONRPCRequest PingRequest where
    requestMethod _ = "ping"

License

MPL-2.0