ArduinoJson , is there a universal function that copes with byte, int, long , float ?

Hi

I am starting to use ArduinoJson 7.3

I am wondering if i someone knows of a 'universal input function' that copes with byte, int, long , float .... being sent to it.

Thanks

If I am understanding you, yes, that is one of the features of OOP languages like C++. I took a 1 min look at ArduinoJson and think it may be possible according to this

What do you mean?

#include <ArduinoJson.h>

void setup() {
  Serial.begin(115200);
  JsonDocument j;
  byte b = 3;
  int i = -1234;
  long l = 8675309;
  float f = 54.3;
  j["byte"] = b;
  j["int"] = i;
  j["long"] = l;
  j["float"] = f;
  serializeJsonPretty(j, Serial);
}

void loop() {}

prints

{
  "byte": 3,
  "int": -1234,
  "long": 8675309,
  "float": 54.3
}

Yes, Serial.print() does just that.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.