Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Double parsed with trailing zeros #206

Copy link
Copy link
@robbienohra

Description

@robbienohra
Issue body actions

Some double values trigger trailing zeros when deserialized.

"field": 1.2932 (of type Double)

Is parsed as 1.2932000000000001

If you change the field to type Float then the value is correctly parsed.

Again only certain numbers appear to be triggering this.

You can replicate the issue like this.

Define:

class Obj {

  Double field;

}

Then execute:

String json = "{ \"field\" : 1.2932}";
Obj obj = JsonIterator.deserialize(json,Obj.class);
System.out.println(obj.getField());
//  1.2932000000000001

Same issue arises even if you use the Any api.

Reactions are currently unavailable

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.