galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
JSON.cpp
Go to the documentation of this file.
1
7
8#include <entt/locator/locator.hpp>
9#include <nlohmann/json.hpp>
10
12
13#include "JSON.hpp"
14
15namespace galaxy
16{
17 namespace json
18 {
19 nlohmann::json read(const std::string& file)
20 {
21 auto& fs = entt::locator<fs::VirtualFileSystem>::value();
22 auto data = fs.read(file);
23
24 return nlohmann::json::parse(data);
25 }
26
27 nlohmann::json read_raw(const std::string& json)
28 {
29 return nlohmann::json::parse(json);
30 }
31
32 bool write(const std::string& file, const nlohmann::json& json)
33 {
34 auto& fs = entt::locator<fs::VirtualFileSystem>::value();
35 return fs.write(json.dump(4), file);
36 }
37
38 std::string dump(const nlohmann::json& json)
39 {
40 return json.dump(4);
41 }
42 } // namespace json
43} // namespace galaxy
nlohmann::json read_raw(const std::string &json)
Read raw json string.
Definition JSON.cpp:27
bool write(const std::string &file, const nlohmann::json &json)
Write json to vfs.
Definition JSON.cpp:32
std::string dump(const nlohmann::json &json)
Dump json to string.
Definition JSON.cpp:38
nlohmann::json read(const std::string &file)
Read a json file in the vfs.
Definition JSON.cpp:19
Timer.hpp galaxy.
Definition Async.hpp:17