Description

ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD specifies the threshold beyond with ArduinoJson uses exponentiation to print small values.

The default is 1e-5, which means that any value smaller than 0.00001 will use the scientific notation.

Examples

Example with 1e-5

The following program uses a threshold of 1e-5:

#define ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD 1e-5
#include <ArduinoJson.h>

void example()
{
  StaticJsonDocument<200> doc;
  JsonObject root = doc.to<JsonObject>();
  root["speed"] = 0.000453;

  serializeJson(doc, Serial);
}

It produces the following output:

{"speed":0.000453}

See online demo on wandbox.org

Example with 1e-2

The following program uses a threshold of 1e-2:

#define ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD 1e-2
#include <ArduinoJson.h>

void example()
{
  StaticJsonDocument<200> doc;
  JsonObject root = doc.to<JsonObject>()
  root["speed"] = 0.000453;

  serializeJson(doc, Serial);
}

It produces the following output:

{"speed":4.53e-4}

See online demo on wandbox.org

See also