This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new df9ce91  [AVRO-1275] Generate "bytes" JSON per spec
df9ce91 is described below

commit df9ce91231d26655ea1fc11ece5132b389fdf860
Author: Daniel Kulp <[email protected]>
AuthorDate: Fri Apr 5 09:40:25 2019 -0400

    [AVRO-1275] Generate "bytes" JSON per spec
---
 .../src/main/java/org/apache/avro/generic/GenericData.java   | 12 ++++++------
 .../test/java/org/apache/avro/generic/TestGenericData.java   |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git 
a/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java 
b/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
index b0a8daf..b628339 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java
@@ -59,7 +59,7 @@ import com.fasterxml.jackson.databind.JsonNode;
 /**
  * Utilities for generic Java data. See {@link GenericRecordBuilder} for a
  * convenient way to build {@link GenericRecord} instances.
- * 
+ *
  * @see GenericRecordBuilder
  */
 public class GenericData {
@@ -182,7 +182,7 @@ public class GenericData {
    * Default implementation of {@link GenericRecord}. Note that this
    * implementation does not fill in default values for fields if they are not
    * specified; use {@link GenericRecordBuilder} in that case.
-   * 
+   *
    * @see GenericRecordBuilder
    */
   public static class Record implements GenericRecord, Comparable<Record> {
@@ -665,10 +665,10 @@ public class GenericData {
       writeEscapedString(datum.toString(), buffer);
       buffer.append("\"");
     } else if (isBytes(datum)) {
-      buffer.append("{\"bytes\": \"");
+      buffer.append("\"");
       ByteBuffer bytes = ((ByteBuffer) datum).duplicate();
       writeEscapedString(StandardCharsets.ISO_8859_1.decode(bytes), buffer);
-      buffer.append("\"}");
+      buffer.append("\"");
     } else if (((datum instanceof Float) && // quote Nan & Infinity
         (((Float) datum).isInfinite() || ((Float) datum).isNaN()))
         || ((datum instanceof Double) && (((Double) datum).isInfinite() || 
((Double) datum).isNaN()))) {
@@ -1139,7 +1139,7 @@ public class GenericData {
 
   /**
    * Gets the default value of the given field, if any.
-   * 
+   *
    * @param field the field whose default value should be retrieved.
    * @return the default value associated with the given field, or null if 
none is
    *         specified in the schema.
@@ -1185,7 +1185,7 @@ public class GenericData {
    * Makes a deep copy of a value given its schema.
    * <P>
    * Logical types are converted to raw types, copied, then converted back.
-   * 
+   *
    * @param schema the schema of the value to deep copy.
    * @param value  the value to deep copy.
    * @return a deep copy of the given value.
diff --git 
a/lang/java/avro/src/test/java/org/apache/avro/generic/TestGenericData.java 
b/lang/java/avro/src/test/java/org/apache/avro/generic/TestGenericData.java
index 9c45815..341da20 100644
--- a/lang/java/avro/src/test/java/org/apache/avro/generic/TestGenericData.java
+++ b/lang/java/avro/src/test/java/org/apache/avro/generic/TestGenericData.java
@@ -373,8 +373,8 @@ public class TestGenericData {
   public void testToStringEscapesControlCharsInBytes() throws Exception {
     GenericData data = GenericData.get();
     ByteBuffer bytes = ByteBuffer.wrap(new byte[] { 'a', '\n', 'b' });
-    assertEquals("{\"bytes\": \"a\\nb\"}", data.toString(bytes));
-    assertEquals("{\"bytes\": \"a\\nb\"}", data.toString(bytes));
+    assertEquals("\"a\\nb\"", data.toString(bytes));
+    assertEquals("\"a\\nb\"", data.toString(bytes));
   }
 
   @Test

Reply via email to