From d198f6ebfe004b4301beb6769a6930c5fefd8af1 Mon Sep 17 00:00:00 2001 From: Jean-Marie Lemetayer Date: Tue, 20 Sep 2016 16:47:35 +0200 Subject: [PATCH] Add support to print unsigned integers Else numbers between INT_MAX and UINT_MAX will be printed using double format --- parson.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/parson.c b/parson.c index a2cc438..e6c2cc6 100644 --- a/parson.c +++ b/parson.c @@ -874,6 +874,8 @@ static int json_serialize_to_buffer_r(const JSON_Value *value, char *buf, int le } if (num == ((double)(int)num)) { /* check if num is integer */ written = sprintf(num_buf, "%d", (int)num); + } else if (num == ((double)(unsigned int)num)) { + written = sprintf(num_buf, "%u", (unsigned int)num); } else { written = sprintf(num_buf, DOUBLE_SERIALIZATION_FORMAT, num); }