F.E.I.S/tests/json_decimal.cpp
2022-03-31 03:50:15 +02:00

30 lines
1.0 KiB
C++

#include <iostream>
#include <map>
#include <cstdint>
#include <string>
#include <vector>
#include <json.hpp>
#include <libmpdec++/decimal.hh>
class json_decimal_parser : public nlohmann::detail::json_sax_dom_parser<nlohmann::json> {
public:
using nlohmann::detail::json_sax_dom_parser<nlohmann::json>::json_sax_dom_parser;
bool number_float(number_float_t /*unused*/, const string_t& val) {
string_t copy = val;
string(copy);
return true;
}
};
int main() {
nlohmann::json j{"blablabla"};
// json_decimal_parser sax{j};
// std::string json;
// std::getline(std::cin, json);
// nlohmann::json::sax_parse(json, &sax);
std::cout << "from const char * {} : " << nlohmann::json{"blablabla"} << std::endl;
std::cout << "from string {} : " << nlohmann::json{std::string{"blibloblu"}} << std::endl;
std::cout << "from const char * () : " << nlohmann::json("blablabla") << std::endl;
std::cout << "from string {} : " << nlohmann::json(std::string("blibloblu")) << std::endl;
}