Skip to content

Regression in 2.15: parsing double value returns BigDecimal instead of Double #39

Closed as not planned
@dlipin

Description

@dlipin

I'm filing this issue as the result of conversation in pull request:
#32

Here is the test:


import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;

public class JsonDoubleTest {

    @Test
    public void testDoubleParsing() throws Exception {
        ObjectMapper objectMapper = new ObjectMapper().registerModule(new JsonOrgModule());
        JSONObject jsonObject = objectMapper.readValue("{\"value\": 0.5 }", JSONObject.class);
        Assert.assertEquals("java.lang.Double", jsonObject.get("value").getClass().getCanonicalName());
    }
}

When I run it with Jackson 2.13.4 then it passes. When I run it with Jackson 2.15.0, it fails with error:

org.junit.ComparisonFailure: 
Expected :java.lang.Double
Actual   :java.math.BigDecimal

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions