27 lines
791 B
Diff
27 lines
791 B
Diff
From d321fa9e6e574ff93518f6384865b9af0a4a4afc Mon Sep 17 00:00:00 2001
|
|
From: AlexanderVasiljev <48011002+AlexanderVasiljev@users.noreply.github.com>
|
|
Date: Wed, 19 Jan 2022 05:30:31 +0300
|
|
Subject: [PATCH] fix: print int without decimal places (#630)
|
|
|
|
---
|
|
cJSON.c | 4 ++++
|
|
1 file changed, 4 insertions(+)
|
|
|
|
diff --git a/cJSON.c b/cJSON.c
|
|
index 3063f74..c78aac6 100644
|
|
--- a/cJSON.c
|
|
+++ b/cJSON.c
|
|
@@ -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 */
|
|
--
|
|
|