Fix invalid JSON

Fix invalid JSON floating point result from nan (Not a Number) and inf (Infinity) into null (#4147)
This commit is contained in:
Theo Arends 2018-10-25 14:03:34 +02:00
parent 51ee22273b
commit eefad54be7
2 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
/* 6.2.1.19 20181023
* Fix header file execution order by renaming user_config.h to my_user_config.h
* Fix invalid JSON floating point result from nan into null (#4147)
* Fix invalid JSON floating point result from nan (Not a Number) and inf (Infinity) into null (#4147)
*
* 6.2.1.18 20181019
* Add more API callbacks and document API.md

View File

@ -196,7 +196,7 @@ int TextToInt(char *str)
char* dtostrfd(double number, unsigned char prec, char *s)
{
if (isnan(number)) {
if ((isnan(number)) || (isinf(number))) { // Fix for JSON output (https://stackoverflow.com/questions/1423081/json-left-out-infinity-and-nan-json-status-in-ecmascript)
strcpy(s, "null");
return s;
} else {