Floating-point NaN or Infinity values should be allowed as a feature #209
Introduce 'allowSpecialFloats' for readers and 'useSpecialFloats' for writers, use consistent macro snprintf definition for writers and readers, provide new unit tests for #209
diff --git a/include/json/reader.h b/include/json/reader.h
index c8ff747..c07ce19 100644
--- a/include/json/reader.h
+++ b/include/json/reader.h
@@ -321,6 +321,9 @@
the JSON value in the input string.
- `"rejectDupKeys": false or true`
- If true, `parse()` returns false when a key is duplicated within an object.
+ - `"allowSpecialFloats": false or true`
+ - If true, special float values (NaNs and infinities) are allowed
+ and their values are lossfree restorable.
You can examine 'settings_` yourself
to see the defaults. You can also write and read them just like any
diff --git a/include/json/writer.h b/include/json/writer.h
index f5f0a38..39bfa9b 100644
--- a/include/json/writer.h
+++ b/include/json/writer.h
@@ -99,6 +99,10 @@
Strictly speaking, this is not valid JSON. But when the output is being
fed to a browser's Javascript, it makes for smaller output and the
browser can handle the output just fine.
+ - "useSpecialFloats": false or true
+ - If true, outputs non-finite floating point values in the following way:
+ NaN values as "NaN", positive infinity as "Infinity", and negative infinity
+ as "-Infinity".
You can examine 'settings_` yourself
to see the defaults. You can also write and read them just like any