[Opensrf-commits] r1228 - trunk/src/libopensrf

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jan 30 12:33:52 EST 2008


Author: erickson
Date: 2008-01-30 12:06:21 -0500 (Wed, 30 Jan 2008)
New Revision: 1228

Modified:
   trunk/src/libopensrf/osrf_legacy_json.c
Log:
updating legacy JSON parser to store numbers as strings

Modified: trunk/src/libopensrf/osrf_legacy_json.c
===================================================================
--- trunk/src/libopensrf/osrf_legacy_json.c	2008-01-29 17:03:41 UTC (rev 1227)
+++ trunk/src/libopensrf/osrf_legacy_json.c	2008-01-30 17:06:21 UTC (rev 1228)
@@ -245,8 +245,7 @@
 	}
 
 	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 @@
 			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;
 		}
 



More information about the opensrf-commits mailing list