Files
json/docs/mkdocs/docs/examples/format_as.cpp
T
Niels Lohmann 8d7e0046f4 Add std::format and fmt support (#5224)
*  add std::format and fmt support

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* ♻️ reorganize PR

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🧛 fix build

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🧛 fix build

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 🧛 fix build

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-07-02 15:59:36 +02:00

17 lines
347 B
C++

#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON value
json j = {{"one", 1}, {"two", 2}};
// format_as() is found via argument-dependent lookup, the same way
// fmt::format/fmt::print would find it
auto j_str = format_as(j);
std::cout << j_str << std::endl;
}