On the server, services are registered with Orbjson using Needle. The library provides libs for CGI or WEBrick handlers to process JSON-RPC calls (such as might be sent from a Web browser using the XmlHttpRequest object).
Orbjson converts the JSON message to a Ruby object (thanks to Florian Frank's code) and locates the appropriate class via Needle (thanks, Jamis). The method invocation results are serialized to JSON and sent back to the client.
The gem depends on Jamis Buck's Needle, which rubygems should automagically download if you do not have it, and Florian's gem for ruby-json, which I believe is only hosted on sourceforge. You will have to install that yourself, as I do not think there is anyway to automate this.
There are examples in the 'examples/' dir. You can also run either
orbjson create-cgi <dirpath>
orbjson create-webrick <dirpath>
to create skeleton code (vielen dank to Michael Neummann; I pilfered his Wee code-creator source for this part).
This is a work in progress. It's pretty straightforward, though.
Comments and patches welcome. Give it a whirl, see what breaks.
I'll release a tar/zip version when I get around to assembling an install.rb file; making a gem is so much easier.
gem install orbjson
JSON-RPC is like XML-RPC, but with, um, JSON:
The jsonrpc.js file was snarfed from a Java project: