nix-vcpkg-cross-experiment/main.cpp

23 lines
501 B
C++
Raw Normal View History

2024-06-22 16:38:19 +02:00
#include <fmt/format.h>
#include <nlohmann/json.hpp>
#include <iostream>
int main()
{
nlohmann::json j;
j["pi"] = 3.141;
j["happy"] = true;
j["name"] = "Niels";
j["nothing"] = nullptr;
j["answer"]["everything"] = 42;
j["list"] = {1, 0, 2};
j["object"] = {{"currency", "USD"}, {"value", 42.99}};
std::string s = j.dump();
std::cout << s << std::endl;
nlohmann::json j2 = nlohmann::json::parse(s);
std::cout << j2.dump(4) << std::endl;
return 0;
}