mirror of
https://github.com/nlohmann/json.git
synced 2026-07-05 10:05:10 +00:00
deploy: 8d7e0046f4
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
json j = {{"one", 1}, {"two", 2}};
|
||||
|
||||
// compact formatting, like dump()
|
||||
std::cout << std::format("{}", j) << "\n\n";
|
||||
|
||||
// pretty-printed formatting, like dump(4)
|
||||
std::cout << std::format("{:#}", j) << "\n\n";
|
||||
|
||||
// a width sets the indent, like dump(2)
|
||||
std::cout << std::format("{:2}", j) << "\n\n";
|
||||
|
||||
// fill-and-align sets the indent character, like dump(4, '.')
|
||||
std::cout << std::format("{:.>#}", j) << std::endl;
|
||||
}
|
||||
Reference in New Issue
Block a user