Home

Awesome

ejrpc2

Erlang JSON-RPC 2 Utility

Example

Given a module testmod:

-module(testmod).
-export([subtract/2]).

subtract(X, Y) ->
  X - Y.

On the erlang shell:

1> Str = "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"subtract\", \"params\":[250,3]}",
2> {ok, R, _} = ejrpc2:handle_req(testmod, Str).
3> io:format("Output: ~s~n", [R]).
Output: {"jsonrpc":"2.0","result":247,"id":1}
ok

Usage of ejrpc2:handle_req(Mod, Str, Opts).

JSON-RPC2 Callbacks should return either:

Notes