New world and player files format

This commit is contained in:
MihailRis
2023-12-03 22:03:59 +03:00
parent b62b7bf2bb
commit 2f9244c17c
6 changed files with 168 additions and 79 deletions
+12 -1
View File
@@ -5,6 +5,7 @@
#include <memory>
#include <stdint.h>
#include <stdexcept>
#include "../coders/json.h"
using std::ios;
using std::string;
@@ -71,4 +72,14 @@ bool files::write_string(path filename, const string content) {
}
file << content;
return true;
}
}
json::JObject* files::read_json(path file) {
string text = files::read_string(file);
try {
return json::parse(file.string(), text);
} catch (const parsing_error& error) {
std::cerr << error.errorLog() << std::endl;
throw std::runtime_error("could not to parse "+file.string());
}
}