Skip to content

double value forced to be treated as string #1556

@jhsenjaliya

Description

@jhsenjaliya

Describe the bug
current implementation of JsonTransformer -> value2String() only allows Double values if fractional part is 0, by the following condition.
(value instanceof Double && BigDecimal.valueOf((Double) value).remainder(BigDecimal.ONE).doubleValue() == 0)

whereas I would expect the double values like 32.59 should be able to treated as number instead of string.

To Reproduce

  1. use schema with field of data type Double
  2. generate the filed value of type Double
    you will find the data generated is:
    {
    "price": "32.59"
    }

Expected behavior
{
"price": 32.59
}

Versions:

  • OS: mac os 15.x
  • JDK - 11
  • Faker Version [e.g. 22] - 1.9.0 - 2.4.3

Additional context
This may not be bug, but I am not able to make sense of treating Double value with additional logic and enforcement of requiring fractional to 0. Happy to convert it into feature request.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions