Skip to content

implicit typecasting #2210

@Faisal-Alsumait

Description

@Faisal-Alsumait

Gson version

2.9.1

Java

java 15.0.1

Used tools

Maven 3.8.1

Description

When mapping String to Object using fromJson method, wrong implicit typecasting was performed

Expected behavior

correct implicit typecasting .

Actual behavior

wrong implicit typecasting .

Reproduction steps

        Gson gson = new Gson();
        String integerNumber = "9";
        String longNumber = "999999999999";
        Object integerValue = gson.fromJson(integerNumber, Object.class);
        Object longValue = gson.fromJson(longNumber, Object.class);
        System.out.println(integerValue.getClass()); //  Expected behavior: class java.lang.Integer, Actual behavior: class java.lang.Double
        System.out.println(longValue.getClass()); //  Expected behavior: class java.lang.Long, Actual behavior: class java.lang.Double

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions