You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Harold Arley Morales <ha...@gmail.com> on 2012/11/07 16:38:29 UTC

Retrieving document representing a form

I am developing an academic project using CouchDB and GWT for UI. What I
have in CouchDB is a form representation (sort of a survey).  Here's the
JSON document:

{
   "_id": "formulario1",
   "_rev": "2-4fe33902cf6117b910ada189253e9753",
   "name": "Gustos musicales",
   "fields": [
       {
           "type": "number",
           "question": "Cuantos años tiene usted?"
       },
       {
           "type": "number",
           "question": "Digite el numero de la localidad en la que
vive actualmente"
       },
       {
           "type": "multiple",
           "question": "Seleccione su nivel más alto de escolaridad",
           "subfields": [
               {
                   "question": "Primaria",
                   "default": "yes"
               },
               {
                   "question": "Bachiller",
               },
               {
                   "question": "Técnico o tecnológico",
               },
               {
                   "question": "Profesional o profesional especializado",

               },
               {
                   "pregunta": "Magíster o PhD",
               }
           ]
       }
   ]
}


I am using LightCouch as an API to CouchDB but might someone please tell me
how could I get an object representation of this JSON. My idea is to take
that object as a base for drawing the form on screen.

Thanks.

Re: Retrieving document representing a form

Posted by Nils Breunese <N....@vpro.nl>.
Harold Arley Morales wrote:

> I am developing an academic project using CouchDB and GWT for UI. What I
> have in CouchDB is a form representation (sort of a survey).  Here's the
> JSON document:
> 
> {
>   "_id": "formulario1",
>   "_rev": "2-4fe33902cf6117b910ada189253e9753",
>   "name": "Gustos musicales",
>   "fields": [
>       {
>           "type": "number",
>           "question": "Cuantos años tiene usted?"
>       },
>       {
>           "type": "number",
>           "question": "Digite el numero de la localidad en la que
> vive actualmente"
>       },
>       {
>           "type": "multiple",
>           "question": "Seleccione su nivel más alto de escolaridad",
>           "subfields": [
>               {
>                   "question": "Primaria",
>                   "default": "yes"
>               },
>               {
>                   "question": "Bachiller",
>               },
>               {
>                   "question": "Técnico o tecnológico",
>               },
>               {
>                   "question": "Profesional o profesional especializado",
> 
>               },
>               {
>                   "pregunta": "Magíster o PhD",
>               }
>           ]
>       }
>   ]
> }
> 
> 
> I am using LightCouch as an API to CouchDB but might someone please tell me
> how could I get an object representation of this JSON. My idea is to take
> that object as a base for drawing the form on screen.

I didn't know about LightCouch and I've never used it, but I'd just look at their documentation. http://www.lightcouch.org/lightcouch-guide.html#docs-api seems to have some examples for the find method which returns JsonObject instances. I think you should be able to work from there.

I don't know if LightCouch is still being developed, but another Java API to look at is Ektorp: http://www.ektorp.org

I've also used jcouchdb in the past, although I don't know if that project is still actively being developed: http://code.google.com/p/jcouchdb/

You could also just skip the CouchDB-specific libraries and take your favorite HTTP client and JSON library and build on that. Most CouchDB libraries aren't much more than that anyway.

Nils.