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 8792D7DA6 for ; Tue, 4 Oct 2011 20:19:56 +0000 (UTC) Received: (qmail 73483 invoked by uid 500); 4 Oct 2011 20:19:56 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 73420 invoked by uid 500); 4 Oct 2011 20:19:56 -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 73331 invoked by uid 99); 4 Oct 2011 20:19:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2011 20:19:56 +0000 X-ASF-Spam-Status: No, hits=-2000.5 required=5.0 tests=ALL_TRUSTED,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; Tue, 04 Oct 2011 20:19:55 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 936562A8666 for ; Tue, 4 Oct 2011 20:19:34 +0000 (UTC) Date: Tue, 4 Oct 2011 20:19:34 +0000 (UTC) From: "Doug Cutting (Updated) (JIRA)" To: dev@avro.apache.org Message-ID: <367494301.9036.1317759574605.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1508907788.8618.1317753694188.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (AVRO-905) make default separator in jsonEncoder to be "\n" instead of " " MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AVRO-905?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Doug Cutting updated AVRO-905: ------------------------------ Fix Version/s: 1.6.0 Assignee: Doug Cutting Status: Patch Available (was: Open) I'll commit this soon unless there are objections. > make default separator in jsonEncoder to be "\n" instead of " " > --------------------------------------------------------------- > > Key: AVRO-905 > URL: https://issues.apache.org/jira/browse/AVRO-905 > Project: Avro > Issue Type: Improvement > Reporter: Yang Yang > Assignee: Doug Cutting > Priority: Minor > Fix For: 1.6.0 > > Attachments: AVRO-905.patch, AVRO-905.patch > > > from mailing list: > if I do > writer = new SpecificDatumWriter(schema); > encoder = EncoderFactory.get().jsonEncoder(schema, ostream); > writer.write(my_specific_record, encoder); > writer.write(my_specific_record.encoder); > it adds a space " " between the 2 records, I guess for separation. > is it possible to remove that? or changing that to "\n" is much better > Doug said: > ...... > or you could pass a JsonGenerator to EncoderFactory#jsonEncoder a > MinimalPrettyPrinter whose rootValueSeparator is set to "\n". > http://jackson.codehaus.org/1.8.4/javadoc/org/codehaus/jackson/util/MinimalPrettyPrinter.html > +++ lang/java/avro/src/main/java/org/apache/avro/io/JsonEncoder.java > (working copy) > @@ -31,6 +31,7 @@ > import org.codehaus.jackson.JsonEncoding; > import org.codehaus.jackson.JsonFactory; > import org.codehaus.jackson.JsonGenerator; > +import org.codehaus.jackson.util.MinimalPrettyPrinter; > /** An {@link Encoder} for Avro's JSON data encoding. > *

> @@ -67,11 +68,17 @@ > } > } > + // by default, one object per line > private static JsonGenerator getJsonGenerator(OutputStream out) > throws IOException { > if (null == out) > throw new NullPointerException("OutputStream cannot be null"); > - return new JsonFactory().createJsonGenerator(out, JsonEncoding.UTF8); > + JsonGenerator g > + = new JsonFactory().createJsonGenerator(out, JsonEncoding.UTF8); > + MinimalPrettyPrinter pp = new MinimalPrettyPrinter(); > + pp.setRootValueSeparator("\n"); > + g.setPrettyPrinter(pp); > + return g; > } -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira