Below is the JSON data that needs to be displayed on a web browser:
{
"testDoubleArr": [1, 2.0, 3.45],
"testStr3": "SHA",
"testDouble1": 12.56,
"testDouble2": 1.0,
"testStr1": "OMG"
}
When displayed on the browser, it appears in the following format:
{
"testDoubleArr": [1, 2, 3.45],
"testStr3": "SHA",
"testDouble1": 12.56,
"testDouble2": 1,
"testStr1": "OMG"
}
The zeros after the decimal point have been removed if they are the only digits present after the decimal point. However, they need to be shown without conversion into a string.
Is there a way to specify the number of significant digits for JavaScript numbers?