]> git.cworth.org Git - apitrace/blobdiff - json.hpp
Remove unused files.
[apitrace] / json.hpp
index ee2a9e03b76286646e5dbdabcb0e388890951ac2..9e6b96004dc71be9dc96e85a6d4279f508c12765 100644 (file)
--- a/json.hpp
+++ b/json.hpp
@@ -34,8 +34,9 @@
 #include <stddef.h>
 #include <wchar.h>
 
-#include <ostream>
 #include <iomanip>
+#include <ostream>
+#include <string>
 
 
 class JSONWriter
@@ -240,6 +241,10 @@ public:
         value = false;
     }
 
+    inline void beginMember(const std::string &name) {
+        beginMember(name.c_str());
+    }
+
     inline void endMember(void) {
         assert(value);
         value = true;
@@ -271,6 +276,10 @@ public:
         space = ' ';
     }
 
+    inline void writeString(const std::string &s) {
+        writeString(s.c_str());
+    }
+
     inline void writeBase64(const void *bytes, size_t size) {
         separator();
         encodeBase64String((const unsigned char *)bytes, size);
@@ -294,10 +303,15 @@ public:
 
     template<class T>
     inline void writeNumber(T n) {
-        separator();
-        os << std::dec << n;
-        value = true;
-        space = ' ';
+        if (n != n) {
+            // NaN
+            writeNull();
+        } else {
+            separator();
+            os << std::dec << std::setprecision(9) << n;
+            value = true;
+            space = ' ';
+        }
     }
     
     inline void writeStringMember(const char *name, const char *s) {