Skip to content

Numbers without decimal numbers are now treated as Double instead of Integers #392

@busches

Description

@busches

Describe the bug
When an number is returned in a json response with no decimal, I'd expect it to be of type Integer, not type Double.

To Reproduce
Steps to reproduce the behavior:

I'm upgrading from the following:

testImplementation("com.konghq:unirest-java:2.3.11")
testImplementation("com.konghq:unirest-objectmapper-jackson:2.3.11")

To:

testImplementation("com.konghq:unirest-java:3.11.06")
testImplementation("com.konghq:unirest-objectmapper-jackson:3.11.06")

I have a json response that returns the following:

{ "integer": 3 }

I'm getting the data like so: Unirest.get("localhost/getInteger").asJson().bodyobject.toMap()["integer"]

Expected behavior
In version 2 that comes over as a type of Integer, now it's coming back as a Double and failing my tests, as assertEquals(3, 3.0) is not true.

Environmental Data:

openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

Additional context
I'm using this inside of a Kotlin application.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions