You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Vlad GURDIGA <gu...@gmail.com> on 2009/10/30 13:20:54 UTC

JSONView to the rescue

I guess everyone starting with CouchDB would like to have a little
nicer error messages.
JSONView* Firefox add-on with a little patch can ease a this pain.

By default it beautifies only responses with content-type
application/json. But this is easy "fixable" if you register it for
text/plain responses too. Yeah, I now it's not a nice and clean
approach but it looks like working for now. :)

Here is how:
- find the jsonview.js in the add-on directory (if you are not able
find it you probably don't want to mess with it, sorry);
- adjust postRegister and preUnregister functions;
- restart Firefox.

* https://addons.mozilla.org/en-US/firefox/addon/10869

Re: JSONView to the rescue

Posted by Sven Helmberger <sv...@gmx.de>.
Zachary Zolton wrote:
> Yeah, I checked that accept header option and it's not working for me
> either...   :^(
> 
> On Fri, Oct 30, 2009 at 8:56 AM, Nils Breunese <n....@vpro.nl> wrote:
>> Vlad GURDIGA wrote:
>>
>>>> You can also just go the add-on's preferences and enable adding
>>>> application/json to the accept header. :o)
>>> That did not work for me because CouchDB responds with Content-Type:
>>> text/plain;charset=utf-8, this is why I came up with the JSONView +
>>> patch...
>> That's strange. If you send an accept header for JSON, then CouchDB should
>> respond with JSON (not text/plain). Works for me.
>>
>> Nils Breunese.
>>
works for me, too. I just needed to make sure it's seeing loading a new 
document because the old, unJSONiprettified one was still in cache.

Re: JSONView to the rescue

Posted by Zachary Zolton <za...@gmail.com>.
Yeah, I checked that accept header option and it's not working for me
either...   :^(

On Fri, Oct 30, 2009 at 8:56 AM, Nils Breunese <n....@vpro.nl> wrote:
> Vlad GURDIGA wrote:
>
>>> You can also just go the add-on's preferences and enable adding
>>> application/json to the accept header. :o)
>>
>> That did not work for me because CouchDB responds with Content-Type:
>> text/plain;charset=utf-8, this is why I came up with the JSONView +
>> patch...
>
> That's strange. If you send an accept header for JSON, then CouchDB should
> respond with JSON (not text/plain). Works for me.
>
> Nils Breunese.
>

Re: JSONView to the rescue

Posted by Nils Breunese <n....@vpro.nl>.
Vlad GURDIGA wrote:

>> You can also just go the add-on's preferences and enable adding
>> application/json to the accept header. :o)
> 
> That did not work for me because CouchDB responds with Content-Type:
> text/plain;charset=utf-8, this is why I came up with the JSONView +
> patch...

That's strange. If you send an accept header for JSON, then CouchDB 
should respond with JSON (not text/plain). Works for me.

Nils Breunese.

Re: JSONView to the rescue

Posted by Vlad GURDIGA <gu...@gmail.com>.
On Fri, Oct 30, 2009 at 2:53 PM, Nils Breunese <n....@vpro.nl> wrote:
> Vlad GURDIGA wrote:
>
>> I guess everyone starting with CouchDB would like to have a little
>> nicer error messages.
>> JSONView* Firefox add-on with a little patch can ease a this pain.
>>
>> By default it beautifies only responses with content-type
>> application/json. But this is easy "fixable" if you register it for
>> text/plain responses too. Yeah, I now it's not a nice and clean
>> approach but it looks like working for now. :)
>>
>> Here is how:
>> - find the jsonview.js in the add-on directory (if you are not able
>> find it you probably don't want to mess with it, sorry);
>> - adjust postRegister and preUnregister functions;
>> - restart Firefox.
>
> You can also just go the add-on's preferences and enable adding
> application/json to the accept header. :o)

That did not work for me because CouchDB responds with Content-Type:
text/plain;charset=utf-8, this is why I came up with the JSONView +
patch...

[vladd@kpax ~]$ curl -v http://localhost:5984/cozy
* About to connect() to localhost port 5984 (#0)
*   Trying ::1... Connection refused
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 5984 (#0)
> GET /cozy HTTP/1.1
> User-Agent: curl/7.19.6 (x86_64-redhat-linux-gnu) libcurl/7.19.6 NSS/3.12.4.1 Beta zlib/1.2.3 libidn/1.9 libssh2/1.0
> Host: localhost:5984
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: CouchDB/0.11.0b825472 (Erlang OTP/R12B)
< Date: Fri, 30 Oct 2009 13:51:46 GMT
< Content-Type: text/plain;charset=utf-8
< Content-Length: 191
< Cache-Control: must-revalidate
<
{"db_name":"cozy","doc_count":14,"doc_del_count":0,"update_seq":46,"purge_seq":0,"compact_running":false,"disk_size":5455961,"instance_start_time":"1256910656926977","disk_format_version":4}
* Connection #0 to host localhost left intact
* Closing connection #0
[vladd@kpax ~]$




>
> Nils Breunese.
>

Re: JSONView to the rescue

Posted by Nils Breunese <n....@vpro.nl>.
Vlad GURDIGA wrote:

> I guess everyone starting with CouchDB would like to have a little
> nicer error messages.
> JSONView* Firefox add-on with a little patch can ease a this pain.
> 
> By default it beautifies only responses with content-type
> application/json. But this is easy "fixable" if you register it for
> text/plain responses too. Yeah, I now it's not a nice and clean
> approach but it looks like working for now. :)
> 
> Here is how:
> - find the jsonview.js in the add-on directory (if you are not able
> find it you probably don't want to mess with it, sorry);
> - adjust postRegister and preUnregister functions;
> - restart Firefox.

You can also just go the add-on's preferences and enable adding 
application/json to the accept header. :o)

Nils Breunese.