Skip to content

Jackson handling of numbers is wrong? #229

@tlefevre

Description

@tlefevre

Groovy script to demonstrate the problem:

@Grab(group='com.fasterxml.jackson.core', module='jackson-databind', version='2.9.10.3')
// @Grab(group='com.google.code.gson', module='gson', version='2.8.6')
@Grab(group='net.javacrumbs.json-unit', module='json-unit', version='2.17.0')

import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals

class Test {

    BigDecimal demo;

    Test(BigDecimal demo) {
        this.demo = demo
    }
}

Test expected = new Test(new BigDecimal("2.00"))
String actual = "{ \"demo\": 2.00 }"

assertJsonEquals(expected, actual)

org.opentest4j.AssertionFailedError: JSON documents are different:
Different value found in node "demo", expected: <2> but was: <2.0>.

But why??

Using gson, it works just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions