Return-Path: X-Original-To: apmail-avro-dev-archive@www.apache.org Delivered-To: apmail-avro-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 43CF76697 for ; Fri, 15 Jul 2011 21:48:33 +0000 (UTC) Received: (qmail 10885 invoked by uid 500); 15 Jul 2011 21:48:32 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 10464 invoked by uid 500); 15 Jul 2011 21:48:31 -0000 Mailing-List: contact dev-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list dev@avro.apache.org Received: (qmail 10445 invoked by uid 99); 15 Jul 2011 21:48:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jul 2011 21:48:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jul 2011 21:48:26 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id B3CD28228A for ; Fri, 15 Jul 2011 21:48:05 +0000 (UTC) Date: Fri, 15 Jul 2011 21:48:05 +0000 (UTC) From: "Scott Carey (JIRA)" To: dev@avro.apache.org Message-ID: <1344900721.18906.1310766485733.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <996782747.14491.1310668679901.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (AVRO-860) Invalid JSON when printing out records with unicode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AVRO-860?page=3Dcom.atlassian.j= ira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D130662= 31#comment-13066231 ]=20 Scott Carey commented on AVRO-860: ---------------------------------- It could be as simple as creating a very simple GenercData.Record with a st= ring field set to have the "=E2=84=A2" in there (you can place unicode utf8= directly in the source, or use a \u literal). {code} Schema s =3D Schema.parse("{\"type\":\"record\", \"fields\": [{\"name":\"ba= r\", \"type\":\"string\"}]}"); GenericData.Record foo =3D new GenericData.Record(s); foo.put(0, "utf8 trademark char-> =E2=84=A2 <-"); Assert.assertEquals(expected, foo.toString()); {code}=20 > Invalid JSON when printing out records with unicode > --------------------------------------------------- > > Key: AVRO-860 > URL: https://issues.apache.org/jira/browse/AVRO-860 > Project: Avro > Issue Type: Bug > Components: java > Affects Versions: 1.5.1 > Reporter: Miki Tebeka > Labels: java, json, unicode > Attachments: AVRO-860.diff > > > I have an avro file, that when printed returns invalid JSON. > The code for iterating and printing is: > {code} > DatumReader reader =3D new GenericDatumReader<= GenericRecord>(); > DataFileReader dataFileReader =3D > new DataFileReader(data, reader); > while (dataFileReader.hasNext()) { > System.out.println(dataFileReader.next().toString()); > } > {code} > and the relevant JSON snippet is > {code} > "description": "Move=E2=84=A2 offers advertisers the opportunity to d= eliver messages to consumers at a time when consumers are making the bigges= t purchases of their lives\uMOVE=E2=84=A2 OFFERS ADVERTISERS THE OPPORTUNIT= Y TO DELIVER MESSAGES TO CONSUMERS AT A TIME WHEN CONSUMERS ARE MAKING THE = BIGGEST PURCHASES OF THEIR LIVES=E2=80=94OR REMODELING, REDECORATING AND MA= INTAINING THEIR MOST IMPORTANT ASSETS.or remodeling, redecorating and maint= aining their most important assets.", > {code} > (The \uMOVE is the problematic part). > However if I do: > {code} > GenericRecord record =3D dataFileReader.next(); > Utf8 desc =3D (Utf8)record.get("description"); > System.out.println(desc); > {code} > Then I get > {code} > Move=E2=84=A2 offers advertisers the opportunity to deliver messages to c= onsumers at a time when consumers are making the biggest purchases of their= lives=E2=80=94or remodeling, redecorating and maintaining their most impor= tant assets. > {code} -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira