fixing int vs double output
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 Sep 2005 20:03:45 +0000 (20:03 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 28 Sep 2005 20:03:45 +0000 (20:03 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1881 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/apachemods/json_xml.c

index 315affd..669bddd 100644 (file)
@@ -112,11 +112,18 @@ void _rest_xml_output(growing_buffer* buf, jsonObject* obj, char * obj_class, in
                }
 
        } else if(obj->type == JSON_NUMBER) {
-               if (notag)
-                       buffer_fadd(buf,"%lf",tag, jsonObjectGetNumber(obj),tag);
-               else
-                       buffer_fadd(buf,"<%s>%lf</%s>",tag, jsonObjectGetNumber(obj),tag);
-
+               double x = jsonObjectGetNumber(obj);
+               if (notag) {
+                       if (x == (int)x)
+                               buffer_fadd(buf,"%d",tag, x,tag);
+                       else
+                               buffer_fadd(buf,"%lf",tag, x,tag);
+               } else {
+                       if (x == (int)x)
+                               buffer_fadd(buf,"<%s>%d</%s>",tag, x,tag);
+                       else
+                               buffer_fadd(buf,"<%s>%lf</%s>",tag, x,tag);
+               }
 
        } else if (obj->type == JSON_ARRAY) {
                if (!notag) {