incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael McCaffrey" <>
Subject RE: valid json string for mochijson2
Date Mon, 31 Aug 2009 20:16:21 GMT
Here's the code I've stolen from the conversion process. Granted, this used to be a POST routine
that I've converted to a GET for my testing/learning purposes...

{FormResp} = csw_view_query_servers:render_view(Lang, UpFun, nil, nil, Req, Db),
couch_httpd:send_json(Req, FormResp); 

render_view(Lang, UpdateFun, DocId, Doc, Req, Db) ->
    Pid = get_os_process(Lang),
    {JsonReqIn} = couch_httpd_external:json_req_obj(Req, Db),

    {JsonReq, JsonDoc} = case {DocId, Doc} of
        {nil, nil} -> {{JsonReqIn}, null};
        {DocId, nil} -> {{append_docid(DocId, JsonReqIn)}, null};
        _ -> {{append_docid(DocId, JsonReqIn)}, couch_doc:to_json_obj(Doc, [revs])}

	try couch_os_process:prompt(Pid, [<<"show_doc">>, UpdateFun, JsonDoc, JsonReq])
        FormResp ->
        ok = ret_os_process(Lang, Pid)

If it requires a erlJSON format, how does one produce this out of couchdb function? 

Thanks again.

-----Original Message-----
From: Paul Davis [] 
Sent: Monday, August 31, 2009 2:00 PM
Subject: Re: valid json string for mochijson2

> So I've got a simple function that just returns a json doc.
> {
>   "getData": "function(doc){ return {\"fld\":\"data\"};}"
> }
> It is called from an erlang module which gets back a FormResp and then calls
> couch_httpd:send_json(Req, FormResp)

Can you paste this bit of Erlang that you're using? If you're using
the map docs interface, then it should be returned as a proper ErlJSON
object but its hard to guess.


View raw message