#include <stddef.h>
#include <wchar.h>
-#include <ostream>
#include <iomanip>
+#include <ostream>
+#include <string>
class JSONWriter
value = false;
}
+ inline void beginMember(const std::string &name) {
+ beginMember(name.c_str());
+ }
+
inline void endMember(void) {
assert(value);
value = true;
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);
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) {