Commit 359e65e4 authored by Kamal Marhubi's avatar Kamal Marhubi

Humor Kenton's NIH (use kj::inf() and kj::isNaN())

parent 3d58431c
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
// THE SOFTWARE. // THE SOFTWARE.
#include "json.h" #include "json.h"
#include <cmath>
#include <unordered_map> #include <unordered_map>
#include <kj/debug.h> #include <kj/debug.h>
...@@ -244,7 +243,7 @@ void JsonCodec::encode(DynamicValue::Reader input, Type type, JsonValue::Builder ...@@ -244,7 +243,7 @@ void JsonCodec::encode(DynamicValue::Reader input, Type type, JsonValue::Builder
case schema::Type::FLOAT64: case schema::Type::FLOAT64:
{ {
double value = input.as<double>(); double value = input.as<double>();
if (std::isinf(value) || std::isnan(value)) { if (kj::inf() == value || -kj::inf() == value || kj::isNaN(value)) {
// These values are not allowed in the JSON spec. Setting the field as null matches the // These values are not allowed in the JSON spec. Setting the field as null matches the
// behavior of JSON.stringify in Firefox and Chrome. // behavior of JSON.stringify in Firefox and Chrome.
output.setNull(); output.setNull();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment