Prettify a JSON string in C++ from a .txt file
You have two choices to prettify with nlohmann.
Uses dump which produces a string
int indent = 4;nlohmann::json data;data.dump(indent);
Or use the stream output overload with field width set
std::ofstream o("pretty.json");o << std::setw(4) << data << std::endl;