Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 853CB9DD1 for ; Sun, 20 Nov 2011 18:00:58 +0000 (UTC) Received: (qmail 99492 invoked by uid 500); 20 Nov 2011 18:00:55 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 99445 invoked by uid 500); 20 Nov 2011 18:00:55 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 99437 invoked by uid 99); 20 Nov 2011 18:00:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Nov 2011 18:00:55 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jens@couchbase.com designates 206.225.164.28 as permitted sender) Received: from [206.225.164.28] (HELO EXHUB020-1.exch020.serverdata.net) (206.225.164.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Nov 2011 18:00:48 +0000 Received: from EXVMBX020-1.exch020.serverdata.net ([169.254.4.147]) by EXHUB020-1.exch020.serverdata.net ([206.225.164.28]) with mapi; Sun, 20 Nov 2011 10:00:25 -0800 From: Jens Alfke To: "user@couchdb.apache.org" CC: "user@couchdb.apache.org" Date: Sun, 20 Nov 2011 10:00:24 -0800 Subject: Re: Erlang view question Thread-Topic: Erlang view question Thread-Index: Acynrkdua/gCWkezQV+2TaEvhUAfuw== Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org I'm pretty sure that you need to return all strings as binary objects, as t= hat's the way Erlang's JSON mapping tells the difference between arrays and= strings. --Jens On Nov 20, 2011, at 9:38 AM, "Luke Bredeson" wrot= e: > Hi, >=20 > I have an Erlang view that is outputting a list of integers instead of a > string. I know Erlang treats strings as lists of integers, but I thought > CouchDB would take care of this for me. I'm sure it's a basic error on m= y > part, so if anyone has any ideas of what I'm doing wrong, I'd appreciate > it! Here's the relevant map function: >=20 > fun({Doc}) -> > case couch_util:get_value(<<"type">>, Doc) of > <<"Crash">> -> > Accdate =3D couch_util:get_value(<<"accdate">>, Doc), > Year =3D string:substr(erlang:bitstring_to_list(Accdate), 7, 4= ), > Emit([couch_util:get_value(<<"city">>, Doc), Year], 1); > _ -> > ok > end > end. >=20 > I get values like: ["3425", [50, 48, 48, 56]], when I'm really looking f= or > values like this: ["3425", "2008"]. >=20 > Thanks, > Luke