[ 
https://issues.apache.org/jira/browse/AVRO-1950?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15642430#comment-15642430
 ] 

Ryan Blue commented on AVRO-1950:
---------------------------------

I've been thinking about this and I think maybe what we should do is to add an 
encoding for Decimal that is a more natural fit for people using JSON. Right 
now, you can store a decimal as bytes or fixed, but that doesn't work well as 
you mentioned. But if we added a String type as well, then that would be suited 
for JSON and wouldn't have a compatibility problem with implementations that 
don't have logical types. This would require adding a String encoding for 
decimal to the spec and toString / fromString methods to the DecimalConversion 
class.

> Better Json serialization for Avro decimal logical types?
> ---------------------------------------------------------
>
>                 Key: AVRO-1950
>                 URL: https://issues.apache.org/jira/browse/AVRO-1950
>             Project: Avro
>          Issue Type: Improvement
>            Reporter: Zoltan Farkas
>            Priority: Minor
>
> Currently as I understand decimal logical types are encoded on top of bytes 
> and fixed avro types. This makes them a bit "unnatural" in the json 
> encoding...
> I worked around a hack in my fork to naturally encode them into json 
> decimals. A good starting point to look at is in: 
> https://github.com/zolyfarkas/avro/blob/trunk/lang/java/avro/src/main/java/org/apache/avro/io/DecimalEncoder.java
>  
> My approach is a bit hacky, so I would be interested in suggestions to have 
> this closer to something we can integrate into avro...



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to