On Wed, May 26, 2010 at 10:09:30AM +0200, Torsten Schönebaum wrote:
>
> > Why not doing it the CouchDB style :
> >
> > GET /_ruote/workitems?wands={"value":101,"type":"Integer"}
>
> That's a great idea. Using JSON's native types, we can even drop the
> "type" key.
>
> > ~~>
> >
> > GET
> > /_ruote/workitems?wands=%7B%22value%22%3A101%2C%22type%22%3A%22Integer%22%7D
> >
> > require 'cgi'
> > CGI.escape('{"value":101,"type":"Integer"}')
> >
> > Granted, the simplest cases now become
> >
> > GET /_ruote/workitems?customer=%22Torsten%22
> >
> > but we could perhaps also accept the plain
> >
> > GET /_ruote/workitems?customer=Torsten
> >
> > without too much worries (if the first char of the value is a % then we
> > know we have to deal with something escaped, else let's assume it's a
> > String).
>
> Sinatra does the url decoding and some parsing on the params so that we
> always get an hash of strings (or even sub-hashes). We could have a look
> at the raw data but I suppose it's easier to check if there are curly
> brackets at the beginning and the end of the filter value and let
> JSON.parse do its work in those cases.
>
> My first try on that is in
> http://github.com/tosch/ruote-kit/commit/a9dc84e7ccd71e0e78d4262ed8be31ea29497620
Hello Torsten,
looks great.
May I suggest to use
Rufus::Json.encode(stuff)
and
Rufus::Json.decode(json_string)
rufus-json is a already a dependency of ruote.
For more info :
http://github.com/jmettraux/rufus-json/
It automatically picks the best JSON lib present. It favours yajl-ruby which is
very fast. It's especially important in those days of borked json gem.
(
http://groups.google.com/group/openwferu-users/browse_thread/thread/caec3b2f2d1c8d39/f9ad7e13aea443a7?lnk=gst&q=SystemStackError#f9ad7e13aea443a7
http://ruote.rubyforge.org/irclogs/ruote_2010-05-25.txt
)
Many thanks,
--
John Mettraux - http://jmettraux.wordpress.com
--
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en