I'm having an issue trying to parse a string to double this would be a sample code, it's returning an integer instead of type :double any ideas?
{
"data": "22" as :number { format: "##.##" }
}
This, and only this, works for me;
%dw 1.0
%output application/json
---
{
data: "22" as :number as :string {format: ".00"} as :number
}
format only seems to add zeros when converting from a number to a string. If "22" would have already been a number you wouldn't need the first :number conversion;
data: 22 as :string {format: ".00"} as :number
The latter number conversion makes it output as a float. Otherwise you would get a string, formatted according to the hosts locale.
And beware. When using%output text/json
instead, the above code will in some cases produces 22.0 instead of 22.00.