Thanks, Brian.
I now create the startkey and endkey as separate arrays and then
JSON.stringify and encodeURIComponent each of them and assemble the url by
hand.
I use jquery as the client side library. Are there any plugins that will do
this for me?
thanks a lot,
mano
On Tue, Mar 2, 2010 at 3:27 PM, Brian Candler <B.Candler@pobox.com> wrote:
> On Tue, Mar 02, 2010 at 02:22:59PM +0530, Manokaran K wrote:
> > I cannot figure out how to encode complex keys in the url - especially
> when
> > numbers are involved. How does futon do it?
>
> 1. encode them into JSON
> 2. URL encode the JSON string
>
> e.g. a plain string: startkey=%22foo%22
>
> a string in array: startkey=%5B%22foo%22%5D
>
> [123,456]: startkey=%5B123%2C456%5D
>
> The encoding rules are in RFC 3986. Basically you must encode all
> "reserved"
> characters - which includes square brackets and comma. Double-quote is not
> listed either as "reserved" or "unreserved", so it's up to you.
>
> Your HTTP client library may have tools for doing the URL-encoding for you.
>
--
Lord, give us the wisdom to utter words that are gentle and tender, for
tomorrow we may have to eat them.
-Sen. Morris Udall
|