Skip to content

LongLazyAny.toString() returns not a string representation of Long value but a chunk of JSON with whitespaces #182

@adiosmsu

Description

@adiosmsu

How to reproduce:

public static void main(String[] args) {
        final String longPropertyAsString = JsonIterator.deserialize("{\"long_property\": 2000, \"foo\": \"bar\"}")
                .get("long_property")
                .toString();
        final Long aLong = Long.valueOf(longPropertyAsString);
    }

Which results in:

Exception in thread "main" java.lang.NumberFormatException: For input string: " 2000"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:578)
at java.lang.Long.valueOf(Long.java:803)
at .........

As you can see actual string returned is " 2000" which is kinda counterintuitive, given that I expect a string representation of a number.

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