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:
18
src/json.hpp
18
src/json.hpp
@ -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";
|
||||
}
|
||||
|
Reference in New Issue
Block a user