Any reasonably complete JSON-RPC ORB projects?

Mixed in with the current churn about JavaScript and XmlHttpRequest
stuff is JSON [0] and JSON-RPC [1]. I've done some assorted RPC stuff
with XmlHttpRequest, but the JSON part looks interesting because it
transfers fewer bytes and may make it easier to build "standardized"
browser services in Ruby. (JSON is JavaScript object notation; like
YAML with C curly-braces instead of Python indentation, and JSON-RPC
is like XML-RPC, but with JSON.)

There is a Java project [2] that seems to do a good job of making the
RPC calls fairly transparent. The client code fetches a list of
methods from the server, and can then invoke method calls almost as if
it had local references to server objects. On the server, one can
register objects with some RPC proxy bridge thing so you don't have to
explicitly enumerate what method calls are available to the client.

So, I have some code that steals some ideas from the Java project
(and, in the browser, uses the same jsonrpc.js file), and works quite
well. Before I get too crazy with this, though, I was wondering if
someone had hadn't already done this (and gotten further than I have).

I've seen two JSON-related Ruby projects; one is a dead-simple JSON
parser [3] (I copped that, too), and the other appears to be an
attempt at Ruby-object JSON serialization, but incomplete[4].

Thanks,

James Britt

[0] http://www.crockford.com/JSON/index.html
[1] http://json-rpc.org/
[2] http://oss.metaparadigm.com/jsonrpc/
[3] http://rubyforge.org/snippet/detail.php?type=snippet&id=29
[4]

I had nearly forgotten this, but a year or so ago I actually wrote
JSON parsers for Ruby and OCaml. They're all here:

ruby talk wrote:

Mixed in with the current churn about JavaScript and XmlHttpRequest
stuff is JSON [0] and JSON-RPC [1]. I've done some assorted RPC stuff
with XmlHttpRequest, but the JSON part looks interesting because it
transfers fewer bytes and may make it easier to build "standardized"
browser services in Ruby. (JSON is JavaScript object notation; like
YAML with C curly-braces instead of Python indentation, and JSON-RPC
is like XML-RPC, but with JSON.)

I've recently written a JSON parser based on Ruby's StringScanner class, that doesn't support the unicode stuff of the specifcation fully yet. A few small examples how it can be used come here:

> puts JSON.pretty_unparse([1,{"foo"=>2,"bar"=>[true,false,nil]},"baz",3.14])
[
  1,
  {
    "foo":2,
    "bar":[
      true,
      false,
      null
    ]
  },
  "baz",
  3.14
]

> p JSON.parse([1,{"foo"=>2,"bar"=>[true,false,nil]},"baz",3.14].to_json)
#=> [1, {"foo"=>2, "bar"=>[true, false, nil]}, "baz", 3.14]

I have attached a copy of the core class to this mail, but I wonder, if I should do a real release (with tests and stuff) on Rubyforge, if you or other people want to build something bigger with it.

json.rb (7.19 KB)

ยทยทยท

--
Florian Frank

Dido Sevilla wrote:

I had nearly forgotten this, but a year or so ago I actually wrote
JSON parsers for Ruby and OCaml. They're all here:

JavaScript Object Notation download | SourceForge.net

Yes, I think I was looking at this earlier. I'm not clear, though, on what it does.

I saw some JSON parsing code, and (I think) some object-to-JSON and array-to-JSON code.

But I'm not sure how I would use it.

James