You can define the connection to your JSON-RPC server with the above procedure.

When defining your connection, you have to give an OUTPUT PORT and INPUT PORT as well as a STRING containing the JSON-RPC version. This implementation is made for version 2.0, so the version string is already set for you as a keyword argument. If a future version is released, I'll try to make it compatible.

For demonstration purposes: Let's define a connection to a XBMC media center, which uses JSON-RPC for its remote calls:

(define xbmc
(json-rpc-server input output))

Once setup, this will return a procedure that accepts a method and optional params. You can then call this procedure to actually send a valid JSON-RPC formatted string to the server. Let's ask the server for a listing of the current active players:

(xbmc "Player.GetActivePlayers")

This will build the following CHICKEN data type:

((jsonrpc . 2.0)(method . Player.GetActivePlayers)(id . 1))

Then it will get formatted to valid JSON and send to the server.

The transformation from CHICKEN data types to JSON (and back) is done trough the wonderful Medea.

You can optionally include params to be send with your method. The JSON-RPC spec defines two types of params:

Positional, which will be represented as literal symbols

Named, which will be represented as keyword arguments

Let's see this in action on the same XBMC connection.

Take, for instance, sending a command to play or pause your XBMC box. Here you not only need to send the method, but also send which player you wish to pause or play. This would look something like the following:

Copyright (c) 2013, Tim van der Linden
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the author nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.