Description

ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD specifies the threshold beyond which ArduinoJson uses scientific notation to print big values

The default is 1e7, which means that any value bigger than 10000000 will use the scientific notation.

Because of the way float-to-string conversion is implemented, this value cannot be larger than 1e9.

Examples

Example with 1e7

The following program uses a threshold of 1e7:

#define ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD 1e7
#include <ArduinoJson.h>

void example()
{
  StaticJsonDocument<200> doc;
  doc["freq"] = 657000.0;
  serializeJson(doc, Serial);
}

It produces the following output:

{"freq":657000}

Example with 1e3

The following program uses a threshold of 1e3:

#define ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD 1e3
#include <ArduinoJson.h>

void example()
{
  StaticJsonDocument<200> doc;
  doc["freq"] = 657000.0;
  serializeJson(doc, Serial);
}

It produces the following output:

{"freq":6.57e5}

See also