updating legacy JSON parser to store numbers as strings
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 30 Jan 2008 17:06:21 +0000 (17:06 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 30 Jan 2008 17:06:21 +0000 (17:06 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1228 9efc2488-bf62-4759-914b-345cdb29e865

src/libopensrf/osrf_legacy_json.c

index a81d46d..40215d5 100644 (file)
@@ -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;
                }