Hi I read in the doc, that "
The pson
data type can hold not only different data types, but also is fully compatible with JSON documents."
Can it be used to move JSON data into a thinger.io device property directly?
e.g. I am querying openweathermaps to get the weather data that way:
void getWeather() {
http.begin(wifiClient, openWeatherMapsURL);
int httpCode2 = http.GET();
if (httpCode2 == HTTP_CODE_OK) {
JSONpayload = http.getString();
JsonDocument doc;
auto error = deserializeJson(doc, JSONpayload.c_str());
if (not error) {
temperature = doc["main"]["temp"];
pressure = doc["main"]["pressure"];
humidity = doc["main"]["humidity"];
wind_speed = doc["wind"]["speed"];
wind_direction = doc["wind"]["deg"];
cloudiness = doc["clouds"]["all"]; // % Clouds
const char* w = doc["weather"][0]["description"];
weather_summary = w;
}
}
http.end();
Then I forward the variables to Thinger in setup() with:
thing["weather"] >> [](pson& out) {
out["temperature"] = temperature;
out["humidity"] = humidity;
out["pressure"] = pressure;
out["wind"] = wind_speed;
out["direction"] = wind_direction;
out["summary"] = weather_summary;
};
Can that be done smarter using the PSON magic?