8000 Set ARDUINOJSON_ENABLE_NAN and ARDUINOJSON_ENABLE_INFINITY to 0 · joglosemarduino/ArduinoJson@4eb8074 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4eb8074

Browse files
committed
Set ARDUINOJSON_ENABLE_NAN and ARDUINOJSON_ENABLE_INFINITY to 0
1 parent 80a02cd commit 4eb8074

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

CHANGELOG.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,31 @@ HEAD
77
* Fixed `deserializeJson()` silently accepting a `Stream*` (issue #978)
88
* Fixed invalid result from `operator|` (issue #981)
99
* Made `deserializeJson()` more picky about trailing characters (issue #980)
10-
* Added `ARDUINOJSON_ENABLE_NAN` to enable NaN in JSON (issue #973)
11-
* Added `ARDUINOJSON_ENABLE_INFINITY` to enable Infinity in JSON
10+
* Added `ARDUINOJSON_ENABLE_NAN` (default=0) to enable NaN in JSON (issue #973)
11+
* Added `ARDUINOJSON_ENABLE_INFINITY` (default=0) to enable Infinity in JSON
1212

13-
> ### BREAKING CHANGE
13+
> ### BREAKING CHANGES
14+
>
15+
> #### NaN and Infinity
16+
>
17+
> The JSON specification allows neither NaN not Infinity, but previous
18+
> versions of ArduinoJson supported it. Now, ArduinoJson behaves like most
19+
> other libraries: a NaN or and Infinity in the `JsonDocument`, becomes
20+
> a `null` in the output JSON. Also, `deserializeJson()` returns
21+
> `InvalidInput` if the JSON document contains NaN or Infinity.
22+
>
23+
> This version still supports NaN and Infinity in JSON documents, but
24+
> it's disabled by default to be compatible with other JSON parsers.
25+
> If you need the old behavior back, define `ARDUINOJSON_ENABLE_NAN` and
26+
> `ARDUINOJSON_ENABLE_INFINITY` to `1`;:
27+
>
28+
> ```c++
29+
> #define ARDUINOJSON_ENABLE_NAN 1
30+
> #define ARDUINOJSON_ENABLE_INFINITY 1
31+
> #include <ArduinoJson.h>
32+
> ```
33+
>
34+
> #### The "or" operator
1435
>
1536
> This version slightly changes the behavior of the | operator when the
1637
> variant contains a float and the user requests an integer.

src/ArduinoJson/Configuration.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@
137137

138138
// Support NaN in JSON
139139
#ifndef ARDUINOJSON_ENABLE_NAN
140-
#define ARDUINOJSON_ENABLE_NAN 1
140+
#define ARDUINOJSON_ENABLE_NAN 0
141141
#endif
142142

143143
// Support Infinity in JSON
144144
#ifndef ARDUINOJSON_ENABLE_INFINITY
145-
#define ARDUINOJSON_ENABLE_INFINITY 1
145+
#define ARDUINOJSON_ENABLE_INFINITY 0
146146
#endif
147147

148148
// Control the exponentiation threshold for big numbers

test/JsonDeserializer/number.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// MIT License
44

55
#define ARDUINOJSON_USE_LONG_LONG 0
6+
#define ARDUINOJSON_ENABLE_NAN 1
7+
#define ARDUINOJSON_ENABLE_INFINITY 1
68

79
#include <ArduinoJson.h>
810
#include <limits.h>

test/Numbers/parseFloat.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// MIT License
44

55
#define ARDUINOJSON_USE_DOUBLE 0
6+
#define ARDUINOJSON_ENABLE_NAN 1
7+
#define ARDUINOJSON_ENABLE_INFINITY 1
68

79
#include <ArduinoJson/Numbers/parseFloat.hpp>
810
#include <catch.hpp>

test/TextFormatter/writeFloat.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <limits>
77
#include <string>
88

9+
#define ARDUINOJSON_ENABLE_NAN 1
10+
#define ARDUINOJSON_ENABLE_INFINITY 1
911
#include <ArduinoJson/Json/TextFormatter.hpp>
1012
#include <ArduinoJson/Serialization/DynamicStringWriter.hpp>
1113

0 commit comments

Comments
 (0)
0