[
https://issues.apache.org/jira/browse/AVRO-1875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15362666#comment-15362666
]
Paul Dudenkov commented on AVRO-1875:
-------------------------------------
[~busbey]
The reason why I want to have Base64 - as of now byte arrays in JSON are
encoded in Latin-1 encoding, which couldn't be displayed by UTF-8. According to
JSON specification (https://tools.ietf.org/html/rfc7159#section-8.1) JSON
should be encoded in UTF-8, 16 or 32, otherwise it is not valid, which causes a
lot of problems when you try parse and work with them with Json libs.
Base64 allows you to see those byte arrays in UTF-8 without loss of data and is
valid from point of view of Json spec.
If you write as it was earlier:
JsonDecoder jsonDecoder = DecoderFactory.get().jsonDecoder(schema,
recordInString);
you will get old version of JsonEncoder, which encodes in Latin-1.
To get Base64 with this patch you need write this:
boolean base64 = true;
JsonDecoder jsonDecoder = DecoderFactory.get().jsonDecoder(schema,
recordInString, base64);
This boolean variable is a member of JsonEncoder and JsonDecoder class and has
default value "false", which means using Latin-1.
> ability encode/decode byte arrays in Base64
> -------------------------------------------
>
> Key: AVRO-1875
> URL: https://issues.apache.org/jira/browse/AVRO-1875
> Project: Avro
> Issue Type: Improvement
> Components: java
> Reporter: Paul Dudenkov
> Fix For: 1.9.0
>
>
> Hi,
> I would like to add ability encode/decode byte arrays in Base64 in classes
> JsonEncoder JsonDecoder.
> For this purpose I will add new constructors and overloaded factory methods.
> Old code will work as before.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)