Having trouble using the JSON.stringify()
method to convert some values into JSON format. The variable amount
is a string and I want the final value in JSON format to be a number, but it's not working as expected. Even after applying JSON.stringify()
, the output remains as "price":"1.00"
. Any suggestions on how to ensure the final value in JSON is a number? Appreciate your assistance!
This is my current code snippet:
var data = JSON.stringify({
"payer": "a cat",
"price": parseFloat(amount).toFixed(2),
});