1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2026-01-07 17:23:07 +01:00
Files
esp32-nmea2000-obp60/lib/boatData/GwBoatData.cpp
2021-10-31 16:31:22 +01:00

30 lines
778 B
C++

#include "GwBoatData.h"
GwBoatData::GwBoatData(GwLog *logger){
this->logger=logger;
}
GwBoatData::~GwBoatData(){
GwBoatItemBase::GwBoatItemMap::iterator it;
for (it=values.begin() ; it != values.end();it++){
delete *it;
}
}
String GwBoatData::toJson() const {
unsigned long minTime=millis();
GwBoatItemBase::GwBoatItemMap::const_iterator it;
size_t count=0;
size_t elementSizes=0;
for (it=values.begin() ; it != values.end();it++){
count++;
elementSizes+=(*it)->getJsonSize();
}
DynamicJsonDocument json(JSON_OBJECT_SIZE(count)+elementSizes);
for (it=values.begin() ; it != values.end();it++){
(*it)->toJsonDoc(&json,minTime);
}
String buf;
serializeJson(json,buf);
return buf;
}