Skip to content

toDouble/toLong uses Exception for control flow when there are leading zeros in the decimal #178

@quom

Description

@quom
String json = "{'key':'1.056'}".replace("'", "\"");
final Any any = JsonIterator.deserialize(json);
any.get("key").toDouble();

Throws a JsonException from the JsonIterator class reportError method creating lots of garbage with the string building. This exception is then eaten up and it reverts back to Double.valueOf().

Is there a reason why an exception is thrown if you try and read a long with leading zeros?

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