1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-09 11:01:47 +03:00

added width feature / more test cases

This commit is contained in:
Niels
2015-02-10 19:50:26 +01:00
parent 4cd341d4db
commit 8c6bb04d10
3 changed files with 78 additions and 15 deletions

View File

@ -1264,14 +1264,20 @@ class basic_json
/// serialize to stream
friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
{
o << j.dump();
// read width member and use it as indentation parameter if nonzero
const int indentation = (o.width() == 0) ? -1 : o.width();
o << j.dump(indentation);
return o;
}
/// serialize to stream
friend std::ostream& operator>>(const basic_json& j, std::ostream& o)
{
o << j.dump();
// read width member and use it as indentation parameter if nonzero
const int indentation = (o.width() == 0) ? -1 : o.width();
o << j.dump(indentation);
return o;
}