From c12d5af100e378663ef5c321316b6a9f39a412ae Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 30 Jan 2008 17:06:21 +0000 Subject: [PATCH] updating legacy JSON parser to store numbers as strings git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1228 9efc2488-bf62-4759-914b-345cdb29e865 --- src/libopensrf/osrf_legacy_json.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/libopensrf/osrf_legacy_json.c b/src/libopensrf/osrf_legacy_json.c index a81d46d..40215d5 100644 --- a/src/libopensrf/osrf_legacy_json.c +++ b/src/libopensrf/osrf_legacy_json.c @@ -245,8 +245,7 @@ int json_parse_json_number(char* string, unsigned long* index, jsonObject* obj, } obj->type = JSON_NUMBER; - obj->value.n = strtod(buf->buf, NULL); - buffer_free(buf); + obj->value.s = buffer_release(buf); return 0; } @@ -744,18 +743,7 @@ char* legacy_jsonObjectToJSON( const jsonObject* obj ) { break; case JSON_NUMBER: { - double x = obj->value.n; - - /* if the number does not need to be a double, - turn it into an int on the way out */ - if( x == (int) x ) { - INT_TO_STRING((int)x); - buffer_add(buf, INTSTR); - - } else { - DOUBLE_TO_STRING(x); - buffer_add(buf, DOUBLESTR); - } + buffer_add(buf, obj->value.s); break; } -- 2.43.2