#pragma once #include #include #include #include #include #include using json = nlohmann::json; //major minor patch #define LITTLESNITCH_VERSION 010 template bool json_get(json j, T& value, K key) noexcept { try { j[key].get_to(value); return true; } catch (nlohmann::detail::type_error& err) { qDebug() << "key " << key << " error " << err.what(); } catch (nlohmann::detail::out_of_range& err) { qDebug() << "key " << key << " error " << err.what(); } catch (nlohmann::detail::other_error& err) { qDebug() << "key " << key << " error " << err.what(); } return false; } template bool json_get(json j, T& value, K key, Ks... keys) noexcept { try { return json_get(j[key], value, keys...); } catch (nlohmann::detail::type_error& err) { qDebug() << "key " << key << " error " << err.what(); } catch (nlohmann::detail::out_of_range& err) { qDebug() << "key " << key << " error " << err.what(); } catch (nlohmann::detail::other_error& err) { qDebug() << "key " << key << " error " << err.what(); } return false; }