// https://www.boost.org/doc/libs/1_92_0/libs/json/doc/html/json/quick_look.html

#include <boost/json.hpp>

#include <cassert>
#include <iostream>
#include <string>

int main()
{
    const std::string text = R"({
        "name": "Boost.Json",
        "version": 1.92,
        "tags": [ "debian", "autopkgtest" ],
        "packaged": true
    })";

    boost::json::value jv = boost::json::parse(text);
    const boost::json::object &obj = jv.as_object();

    std::cout << "name    = " << obj.at("name").as_string() << std::endl;
    std::cout << "version = " << obj.at("version").as_double() << std::endl;
    std::cout << "tags    = " << boost::json::serialize(obj.at("tags")) << std::endl;

    assert(obj.at("name").as_string() == "Boost.Json");
    assert(obj.at("packaged").as_bool() == true);
    assert(obj.at("tags").as_array().size() == 2);

    // Serialise back and re-parse: the value must survive the round trip
    const std::string out = boost::json::serialize(jv);
    assert(boost::json::parse(out) == jv);

    return 0;
}
