From: José Fonseca Date: Fri, 6 May 2011 19:49:45 +0000 (+0100) Subject: Handle NaNs in JSON. X-Git-Tag: 2.0_alpha^2~947 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=364a5a6e8476237913ee5b19bbebbbbd3e2eda37;p=tools%2Fapitrace.git Handle NaNs in JSON. --- diff --git a/json.hpp b/json.hpp index 24d9c87..d13793e 100644 --- a/json.hpp +++ b/json.hpp @@ -294,10 +294,15 @@ public: template inline void writeNumber(T n) { - separator(); - os << std::dec << std::setprecision(9) << 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) {