[
https://issues.apache.org/jira/browse/AVRO-1584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15038210#comment-15038210
]
Ryan Blue commented on AVRO-1584:
---------------------------------
I agree that this seems like a bug, but while looking at AVRO-1746 recently I
found out that the spec actually states that [bytes 0-255 should be mapped to
unicode code points
0-255|https://avro.apache.org/docs/1.7.7/spec.html#schema_record]. After that,
several characters need to be escaped as required by the JSON spec, but
otherwise the unicode characters are allowed in JSON. So I think what Java does
currently is the correct behavior, however it does seem odd.
> Json output doesn't generate base64 for byte arrays
> ---------------------------------------------------
>
> Key: AVRO-1584
> URL: https://issues.apache.org/jira/browse/AVRO-1584
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.7.7
> Environment: Pure java.
> Reporter: Christophe Lorenz
> Attachments: AVRO-1584.patch
>
>
> The Json output of java generated code doesn't correctly encode byte arrays.
> Using this simple schema :
> {"namespace": "example.avro",
> "type": "record",
> "name": "ByteArrayEncoding",
> "fields": [ {"name": "data", "type": "bytes"} ]
> }
> The toString()
> System.out.println(new ByteArrayEncoding(ByteBuffer.wrap(new
> byte[]{0,31,65,66,67,(byte)255,(byte)182})));
> Returns raw bytes to string in the json :
> {"data": {"bytes": " ABC??"}}
> As a byte array is not tied to be a valid string, it should be converted back
> and forth to Base64 like other Json implementations :
> {"data": {"bytes": "AB9BQkP/tg=="}}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)