diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-01-10 13:51:10 -0800 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-01-10 13:51:10 -0800 |
| commit | a064e19b8a78d3809e9f80fba010e0f53197c1a2 (patch) | |
| tree | f3c92cea64dc0ed4eb66f56979d1ef252adb2355 /controller/JSONDB.cpp | |
| parent | 6fb49f68fc2ac3539732794f553f635610c92ef2 (diff) | |
| download | infinitytier-a064e19b8a78d3809e9f80fba010e0f53197c1a2.tar.gz infinitytier-a064e19b8a78d3809e9f80fba010e0f53197c1a2.zip | |
Refactor some JSON stuff for performance, and fix a build error.
Diffstat (limited to 'controller/JSONDB.cpp')
| -rw-r--r-- | controller/JSONDB.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/controller/JSONDB.cpp b/controller/JSONDB.cpp index dfea9dd1..4747e470 100644 --- a/controller/JSONDB.cpp +++ b/controller/JSONDB.cpp @@ -31,7 +31,7 @@ bool JSONDB::put(const std::string &n,const nlohmann::json &obj) if (!path.length()) return false; - const std::string buf(obj.dump(2)); + const std::string buf(OSUtils::jsonDump(obj)); if (!OSUtils::writeFile(path.c_str(),buf)) return false; @@ -69,7 +69,7 @@ const nlohmann::json &JSONDB::get(const std::string &n,unsigned long maxSinceChe if (e->second.lastModifiedOnDisk != lm) { if (OSUtils::readFile(path.c_str(),buf)) { try { - e->second.obj = nlohmann::json::parse(buf); + e->second.obj = OSUtils::jsonParse(buf); e->second.lastModifiedOnDisk = lm; // don't update these if there is a parse error -- try again and again ASAP e->second.lastCheck = now; @@ -91,7 +91,7 @@ const nlohmann::json &JSONDB::get(const std::string &n,unsigned long maxSinceChe const uint64_t lm = OSUtils::getLastModified(path.c_str()); _E &e2 = _db[n]; try { - e2.obj = nlohmann::json::parse(buf); + e2.obj = OSUtils::jsonParse(buf); } catch ( ... ) { e2.obj = _EMPTY_JSON; buf = "{}"; |
