1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-10 22:00:59 +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;
}
@ -1315,24 +1321,28 @@ class basic_json
{
return "null";
}
case (value_t::object):
{
return "object";
}
case (value_t::array):
{
return "array";
}
case (value_t::string):
{
return "string";
}
case (value_t::boolean):
{
return "boolean";
}
case (value_t::number_integer):
case (value_t::number_float):
default:
{
return "number";
}