[Nitro] Fwd: Nitro + JSONORB

George Moschovitis george.moschovitis at gmail.com
Thu Mar 24 08:10:45 EST 2005

forwarded with permission, so more people can comment on this.

---------- Forwarded message ----------
From: James Britt <james_b at neurogami.com>
Date: Wed, 23 Mar 2005 08:09:23 -0700
Subject: Re: Nitro + JSONORB
To: George Moschovitis <george.moschovitis at gmail.com>

George Moschovitis wrote:
> Btw,
> Is there some way we could integrate your JSON library with Nitro?
> Have you tried this? Any ideas?

It crossed  my mind, especially after I read about the alleged AJAX
support in Rails (I say alleged because I think it uses HTML not XML;
it's sort of AJAX-lite).

I haven't used it, but I get the impression it is good for certain cases
(passing complete HTML down to the client) but less so for the more
general (and arguably more powerful) case where you want the client to
manage complex data structures.

Earlier this week, someone on the Rails list asked about integrating
Orbjson with Rails; I replied with an example that took about 30 minutes
to assemble, including my explanation and sample code.

I'll see what's involved with doing this for Nitro.  The harder part
really is thinking through the API, how to make this fairly transparent
to the developer.  Orbjson needs a configuration hash/YAML string, which
can be defined in run.rb or someplace similar, and a class that derives
from the the core Orbjson::Common code.  And then you just need an end
point that takes the raw POST data and hands it off to that
Orbjson-derived class and spits back the results.

If the a  N::Orbjson class were already defined, I think one could
simply d this

require 'nitro/json'

def jsonrpc
   @out = Njson.process

I'm thinking now that if you allow for a default end-point of /jsonrpc
there may be no need to write anything other than the service
registration YAML.  The controller/action part for my Rails hack was this:

class ServicesController < ApplicationController

    def jsonrpc
     # Not sure of the Official Rails API for
     # this.  I hacked my own, available upon request.
      post = get_raw_post_data
      render_text( ORBJSON.process( post ) )


and the endpoint was /services/jsonrpc

That's something can be built-in, I think.  Just define the services and
Nitro would know what to do after that.  Zero lines of code.  "There's
no step 1!"

Anyway, I'll take a look.



More information about the Nitro-general mailing list