Mercurial > minori
view src/core/json.cc @ 83:d02fdf1d6708
*: huuuge update
1. make the now playing page function correctly
2. de-constructorfy many of our custom widgets,
allowing them to be changed on-the-fly from
the Now Playing page
3. ... :)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 24 Oct 2023 22:01:02 -0400 |
parents | 9b2b41f83a5e |
children | f88eda79c60a |
line wrap: on
line source
#include "core/json.h" namespace JSON { std::string GetString(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, std::string def) { if (json.contains(ptr) && json[ptr].is_string()) return json[ptr].get<std::string>(); else return def; } int GetInt(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, int def) { if (json.contains(ptr) && json[ptr].is_number()) return json[ptr].get<int>(); else return def; } bool GetBoolean(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, bool def) { if (json.contains(ptr) && json[ptr].is_boolean()) return json[ptr].get<bool>(); else return def; } double GetDouble(const nlohmann::json& json, const nlohmann::json::json_pointer& ptr, double def) { if (json.contains(ptr) && json[ptr].is_number()) return json[ptr].get<double>(); else return def; } } // namespace JSON