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.

:warning: 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()
{
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& root = jsonBuffer.createObject();
  root["freq"] = 657000.0;

  root.printTo(Serial);
}

It produces the following output:

{"freq":657000}

See online demo on wandbox.org

Example with 1e3

The following program uses a threshold of 1e3:

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

void example()
{
  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& root = jsonBuffer.createObject();
  root["freq"] = 657000.0;

  root.printTo(Serial);
}

It produces the following output:

{"freq":6.57e5}

See online demo on wandbox.org

See also