//# This file is a part of toml++ and is subject to the the terms of the MIT license. //# Copyright (c) 2019-2020 Mark Gillard //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #include "tt.h" using nlohmann::json; using namespace std::string_view_literals; TOML_NAMESPACE_START { static void to_json(json & j, const value& val) { j["type"] = "string"; j["value"] = *val; } template static void to_json_via_stream(json & j, const value& val) { static constexpr auto flags = toml_formatter::default_flags & ~(format_flags::allow_binary_integers // | format_flags::allow_hexadecimal_integers // | format_flags::allow_octal_integers); std::ostringstream ss; ss << toml_formatter{ val, flags }; j["value"] = ss.str(); } static void to_json(json & j, const value& val) { j["type"] = "integer"; to_json_via_stream(j, val); } static void to_json(json & j, const value& val) { j["type"] = "float"; to_json_via_stream(j, val); } static void to_json(json & j, const value& val) { j["type"] = "bool"; to_json_via_stream(j, val); } static void to_json(json & j, const value& val) { j["type"] = "date-local"; to_json_via_stream(j, val); } static void to_json(json & j, const value