question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LongNode(3) != IntNode(3)

See original GitHub issue

The equals method for IntNode is implemented so that only IntNodes can be equal to other IntNodes, regardless of numeric value. This is obvious with just a glance at the source code.

I can do a PR to fix this, but just want to confirm that this isn’t so by design first.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cowtowncodercommented, Sep 1, 2017

I appreciate your reaching out first: makes sense.

This is by design, wrt default behavior. Users are encouraged to use

   public boolean equals(Comparator<JsonNode> comparator, JsonNode other);

method with suitable Comparator implementation for customizing equality logic to their liking.

The reason here is simply that attempting to support various kinds of coercion (DoubleNode, FloatNode too, presumably; BigIntegerNode, BigDecimalNode) leads to unmaintanable system. So although I agree in that it is not unreasonable to expect equality here, I am not interested in following this trail down the likely rat hole.

0reactions
cowtowncodercommented, Nov 21, 2019

@grimsa Thank you for sharing this!

I wonder if there was some benefit to adding a configurable (Builder based) JsonNodeComparator on Jackson 2.11 or later? (possibly 3.0, to allow Java 8 method pointers)

Read more comments on GitHub >

github_iconTop Results From Across the Web

AssertJ: how can I make JsonNode comparison handle ...
The 3 in the actual node is a LongNode (which I understand since the original map contains a 3L ); The 3 in...
Read more >
com.fasterxml.jackson.databind.node.LongNode Java Examples
This page shows Java code examples of com.fasterxml.jackson.databind.node.LongNode.
Read more >
LongNode (jackson-databind 2.6.0 API) - FasterXML
Numeric node that contains simple 64-bit integer values. Nested Class Summary. Nested classes/interfaces inherited from interface com.fasterxml.jackson.
Read more >
NumericNode (jackson-databind 2.12.4 API) - Javadoc.io
Returns integer value for this node (as BigDecimal ), if and only if this node is numeric ( JsonNode.isNumber() returns true). abstract boolean ......
Read more >
jackson-mapper-asl-1.6.3.jar
Name, jackson-mapper-asl-1.6.3.jar ; Class Version, Java 5 ; Locations. /tmp/jboss-as-7.1.0.Alpha2-SNAPSHOT/modules/org/codehaus/jackson/jackson-mapper-asl/main/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found