boost::json How to serialize to std::string minimal example

#include <boost/json.hpp>
#include <fstream>
#include <iostream>

namespace json = boost::json;

int main() {
    // Create a JSON object
    json::object obj{
        {"name", "John Doe"},
        {"age", 30},
        {"city", "New York"}
    };

    // Serialize the JSON object
    std::string serialized = json::serialize(obj);

    // Example of what to do with the serialized JSON
    std::cout << serialized << std::endl;

    return 0;
}

Compile using:

g++ -o main main.cpp -lboost_json

Running the program using ./main will print

{"name":"John Doe","age":30,"city":"New York"}