diff --git a/src/DeviceTypeCache.h b/src/DeviceTypeCache.h index 36d11b3..a4e33cd 100644 --- a/src/DeviceTypeCache.h +++ b/src/DeviceTypeCache.h @@ -63,17 +63,9 @@ namespace OpenWifi { std::lock_guard G(Mutex_); Initialized_ = true; - std::string DeviceTypes; - if (AppServiceRegistry().Get("deviceTypes", DeviceTypes)) { - Poco::JSON::Parser P; - try { - auto O = P.parse(DeviceTypes).extract(); - for (const auto &i : *O) { - DeviceTypes_.insert(i.toString()); - } - } catch (...) { - } - } + std::vector DeviceTypes; + AppServiceRegistry().Get("deviceTypes", DeviceTypes); + std::for_each(DeviceTypes.begin(),DeviceTypes.end(),[&](const std::string &s){ DeviceTypes_.insert(s);}); } inline bool UpdateDeviceTypes() { @@ -107,15 +99,9 @@ namespace OpenWifi { inline void SaveCache() { std::lock_guard G(Mutex_); - - Poco::JSON::Array Arr; - for (auto const &i : DeviceTypes_) - Arr.add(i); - - std::stringstream OS; - Arr.stringify(OS); - - AppServiceRegistry().Set("deviceTypes", OS.str()); + std::vector DeviceTypes; + std::for_each(DeviceTypes_.begin(),DeviceTypes_.end(),[&](const std::string &s){DeviceTypes.emplace_back(s);}); + AppServiceRegistry().Set("deviceTypes", DeviceTypes); } }; diff --git a/src/framework/AppServiceRegistry.h b/src/framework/AppServiceRegistry.h index 074e4ec..49c1e90 100644 --- a/src/framework/AppServiceRegistry.h +++ b/src/framework/AppServiceRegistry.h @@ -66,7 +66,7 @@ namespace OpenWifi { } bool Get(const char *key, std::vector &Value) { - if(Registry_->has(key) && Registry_->isArray(key)) { + if(Registry_->has(key) && !Registry_->isNull(key) && Registry_->isArray(key)) { auto Arr = Registry_->get(key); for(const auto &v:Arr) { Value.emplace_back(v);