Mercurial > minori
view src/core/json.cpp @ 64:fe719c109dbc
*: update
1. add media tracking ability, and it displays info on the `now playing` page
2. the `now playing` page now actually shows something
3. renamed every page class to be more accurate to what it is
4. ...
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 01 Oct 2023 23:15:43 -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