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

Ryan Skraba commented on AVRO-2343:
-----------------------------------

(Opinion alert!) I think the real bug is that *{{toString}}* _looks_ like JSON 
in the first place.  Code that parses this string is likely to be flawed or 
fragile with respect to future behaviour, and we probably shouldn't pretend 
otherwise!

A bit more detail:
 * [Never use toString() for behaviour|https://java.christmas/2019/4]
 * [Java toString() 
Considerations|https://www.javaworld.com/article/2073619/java-tostring---considerations.html]
 (Know thy audience)

In the meantime, I don't see any reason not to fix this, but it should really 
not be encouraged.

I don't think it should be a goal to maintain stability for the return value of 
toString across versions either.  If you need stable and well-specified JSON 
from Avro datum, the JsonEncoder and JsonDecoder are the right way to go.

> Invalid json string caused by logic timestamp millis
> ----------------------------------------------------
>
>                 Key: AVRO-2343
>                 URL: https://issues.apache.org/jira/browse/AVRO-2343
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.8.1, 1.8.2
>            Reporter: 富恒
>            Priority: Major
>
> I am trying to use timestamp millis. The generated java code cannot be 
> converted to an invalid json message, because the ISO timestamp is not 
> correctly quoted.
> It will generate json, where the value is invalid, like:
> {"timestamp": 2019-03-09T21:45:39.594-08:00}
> instead of
> {"timestamp": "2019-03-09T21:45:39.594-08:00"}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to