An initial gem release of Ruby Orbjson is available. It provides an ORB (object request broker) for facilitating JavaScript/Ruby interaction using JSON-RPC.
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>
or
orbjson create-webrick <dirpath>
to create skeleton code (vielen dank to Michael Neummann; I pilfered his Wee code-creator source for this part).
The example client page use the jsonrpc.js script from Jan-Klaas Kollhof and Michael Clark, which is based on Jan-Klaas' JavaScript o lait library (jsolait). I'm not entirely happy with that code (I'd consider some different design choices for more fluid JavaScript client behavior), but it's good and it works.
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.
Download:
http://rubyforge.org/projects/orbjson/
or
gem install orbjson
ruby-json:
http://cvs.sourceforge.net/viewcvs.py/json/ruby-json/
JSON (JavaScript Object Notation):
http://www.crockford.com/JSON/
JSON-RPC is like XML-RPC, but with, um, JSON:
http://www.json-rpc.org/
The jsonrpc.js file was snarfed from a Java project:
http://oss.metaparadigm.com/jsonrpc/
James Britt