Hi @dchiesa1 ,
We're working on a response payload transformation. We're using javascript to do it as the response payload consists of lots of arrays. Here there's a field where we receive it as float and we need to pass a float to source systems.
But JS is somehow converting the float to int when decimal part contains only zeros. For example,
if responsePayload.x = 5.009, our js is passing it as it is.
But if responsePayload.x = 5.00, our js is converting it into just 5(which is not acceptable). Is there any way to stop our float getting converted into into int when decimal part contains only zeros? Could someone please help?
Attaching a sample code for reference:
var payload = JSON.parse('{"name":"John", "age":30.000, "city":"New York"}');
var floaT = 0.00;
var page = payload.age.toFixed(5);
console.log(page)
let finalResponse={
name: payload.name,
age: payload.age,
hi: floaT
}
frs = JSON.stringify(finalResponse)
console.log(frs)
Response:
30.00100
{"name":"John","age":30,"hi":0}
P.S. We dont want to convert tis into string, for example "30.000". We just need to pass as float along the trailing zeros.
Thanks in advance!
Manoj T.