Fields serialized as "null" when including other library that messes with nullptr definition.
Created by: dr-gino
Targeting ESP8266 using PlatformIO. Long story short: I was including a library (Arduino-Temperature-Control-Library) before including ArduinoJson.h and it caused ArduinoJson to always generate null values for some fields that were supposed to contain non-0 integer values. (At first I though there were memory issues, but there was plenty available). It seems that Arduino-Temperature-Control-Library does the following in its header file:
#ifndef nullptr
#define nullptr NULL
#endif
Including ArduinoJson.h before the other library fixes this, and obviously just redefining nullptr like that is bad behavior. However this bug took me hours to resolve as no obvious errors/warnings were thrown.
Two questions:
- How exactly does it cause the behavior I was seeing?
- Can anything be done in ArduinoJson to warn the user/be more defensive? The Arduino Temperature Control Library is pretty popular for reading out DS18b20 temperature sensors. I might not be the first one encountering this issue.