fix: print int without decimal places (#630)

This commit is contained in:
AlexanderVasiljev 2022-01-19 05:30:31 +03:00 committed by GitHub
parent 203a0dec6f
commit d321fa9e6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -562,6 +562,10 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
{
length = sprintf((char*)number_buffer, "null");
}
else if(d == (double)item->valueint)
{
length = sprintf((char*)number_buffer, "%d", item->valueint);
}
else
{
/* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */