Skip to content

ObjectTypeAdapter error when the value type is a Number #1257

@marcgise

Description

@marcgise

Hi,
I found an error in the read method of the ObjectTypeAdapter when the value is a Number, as it always transforms it to a double value. But maybe the expected value is an Integer. I made the following change, and it seems to work fine:

switch (token) {
    case NUMBER:
        String value = in.nextString();
        if (value.contains(",") || value.contains(".")) {
            return new BigDecimal(value); // or Double.valueOf(value);
        } else {
            return Integer.valueOf(value);
        }
    case....:
}

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