You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Christophe Le Saec (Jira)" <ji...@apache.org> on 2023/09/28 13:37:00 UTC
[jira] [Created] (AVRO-3876) JacksonUtils is not symmetric
Christophe Le Saec created AVRO-3876:
----------------------------------------
Summary: JacksonUtils is not symmetric
Key: AVRO-3876
URL: https://issues.apache.org/jira/browse/AVRO-3876
Project: Apache Avro
Issue Type: Bug
Reporter: Christophe Le Saec
Assignee: Christophe Le Saec
For each json node, you should have
{code:java}
Object object = JacksonUtils.toObject(node);
JsonNode node1 = JacksonUtils.toJsonNode(object);
Assertions.assertEquals(node, node1);
{code}
But, that's not true for
{code:java}
JsonNodeFactory.instance.numberNode(33.33000183105469f);
{code}
where test give
{noformat}
org.opentest4j.AssertionFailedError:
Expected :33.33
Actual :33.33000183105469
{noformat}
because toObject method transform float to double and by default, Float.toString method gives round values, as this code
{code:java}
float x = 33.33000183105469f;
System.out.println("value float = " + x);
System.out.println("value double = " + (double) x);
{code}
shows
{noformat}
value float = 33.33
value double = 33.33000183105469
{noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)