Mercurial > minori
view src/core/json.cpp @ 46:d0adc4aedfc8
*: update...
this commit:
1. consolidates dark theme stuff to dark_theme.cpp
2. creates a new widgets folder to store all of our
custom widgets
3. creates the list settings page in the information
dialog, although much of it is nonfunctional: it
doesn't save, and the status doesn't even get filled
in... we'll fix this later!
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sat, 23 Sep 2023 01:02:15 -0400 |
parents | 5c0397762b53 |
children |
line wrap: on
line source
#include "core/json.h" namespace JSON { std::string GetString(nlohmann::json const& json, nlohmann::json::json_pointer const& ptr, std::string def) { if (json.contains(ptr) && json[ptr].is_string()) return json[ptr].get<std::string>(); else return def; } int GetInt(nlohmann::json const& json, nlohmann::json::json_pointer const& ptr, int def) { if (json.contains(ptr) && json[ptr].is_number()) return json[ptr].get<int>(); else return def; } bool GetBoolean(nlohmann::json const& json, nlohmann::json::json_pointer const& ptr, bool def) { if (json.contains(ptr) && json[ptr].is_boolean()) return json[ptr].get<bool>(); else return def; } double GetDouble(nlohmann::json const& json, nlohmann::json::json_pointer const& ptr, double def) { if (json.contains(ptr) && json[ptr].is_number()) return json[ptr].get<double>(); else return def; } } // namespace JSON