Skip to content

dw::util::Coercions toNumber : not-significant zeros #456

@CYDER77

Description

@CYDER77

Since - to my knowledge - Runtime 4.6, it seems that the output number in json systematically removes not-significant zeros.

As an example :

This input

%dw 2.0
import * from dw::util::Coercions
output application/json
---
 {
     "simpleNumber": 1.230,
     "toNumber": toNumber("1.2300"),
     "asNumber": 1.23000 as Number {format:"00.000"}
 }

Outputs

{
  "simpleNumber": 1.23,
  "toNumber": 1.23,
  "asNumber": 1.23
}

Therefore, either there is a bug in Dataweave, either the documentation is wrong here :
dw-coercions-functions-tonumber.adoc & MuleSoft Docs

It should be :

Output

{
  "default": 1,   //  <---- here is the change
  "withFormat": 0.005,
  "withLocal": 1.25,
  "withExtraPlaceholders": 5.55,
  "keyToNumber": 123
}

Metadata

Metadata

Assignees

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