fixing int vs double output
[working/Evergreen.git] / Open-ILS / src / apachemods / json_xml.c
index 0cd42a4..669bddd 100644 (file)
@@ -76,10 +76,10 @@ void _rest_xml_output(growing_buffer* buf, jsonObject* obj, char * obj_class, in
    /* add class hints if we have a class name */
    if(obj->classname) {
        if(obj->type == JSON_NULL) {
-                       buffer_fadd(buf,"<%s><Object class_hint=\\\"%s\\\"/></%s>", tag, obj->classname, tag);
+                       buffer_fadd(buf,"<%s><Object class_hint=\"%s\"/></%s>", tag, obj->classname, tag);
                        return;
                } else {
-                       buffer_fadd(buf,"<%s><Object class_hint=\\\"%s\\\">", tag, obj->classname);
+                       buffer_fadd(buf,"<%s><Object class_hint=\"%s\">", tag, obj->classname);
                }
        }
 
@@ -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) {