RFC4627 (JSON) and JSON-RPC for Erlang
An implementation of JSON and JSON-RPC for Erlang.
See rfc4627.erl, the JSON/RFC4627 codec itself, to learn how to encode and decode JSON objects from Erlang code.
Providing and calling JSON-RPC services
See rfc4627_jsonrpc.erl, a JSON-RPC service registry and transport-neutral service method invocation mechanism, to learn how to expose Erlang processes as remotely-callable JSON-RPC services, and to learn how to invoke local JSON-RPC services from Erlang without the overhead of HTTP.
Exposing JSON-RPC services over HTTP
See rfc4627_jsonrpc_inets.erl, an Inets HTTP transport binding for JSON-RPC, to learn how to configure the Inets HTTP server to respond to JSON-RPC requests.
See rfc4627_jsonrpc_mochiweb.erl to learn how to delegate incoming Mochiweb HTTP requests to the JSON-RPC service dispatcher.
See rfc4627_jsonrpc_cowboy.erl to learn how to delegate incoming Cowboy HTTP requests to the JSON-RPC service dispatcher.
Running the example test service that comes with the source code
At your Erlang shell,
- after compiling the code with
make all test-compile,
- when your current working directory contains the
testdirectory from the distribution, such that
test_jsonrpc_inets:start_httpd(). (Don't forget the trailing
"."!) This will
- start the inets httpd on port 5671 (from
- allow HTTP access to JSON-RPC services via a url prefix of
- start the
- register the test service
See the relevant
edoc documentation included with the source code.
the JSON RFC.
Joe Armstrong's message describing the basis of the JSON data type mapping that the
The codebase and documentation was originally written between 2007 and 2010 by Tony Garnock-Jones while at LShift in London. Since then, it has been maintained by Tony and enhanced with a few generous contributions from others:
- András Veres-Szentkirályi
- Eugene Volchek
- Simon MacMullen
- Andrey Khozov
- Erik Timan
Copyright and Licence
- Copyright © 2007-2010, 2011, 2012 Tony Garnock-Jones.
- Portions copyright 2007-2010 LShift Ltd.
- Portions copyright contributors to the project, listed above.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.