对于[1,2,3...]这样的纯数值json,使用dump(4)输出会占用非常多的行:
[
1,
2,
3,
。。。
]
我个人喜欢对这样的纯数值,只用一行,所以小改了一下源代码:
void dump(const BasicJsonType& val, const bool pretty_print,
const bool ensure_ascii,
const unsigned int indent_step,
const unsigned int current_indent = 0)
...
case value_t::array:
{
if (val.m_value.array->empty())
{
o->write_characters("[]", 2);
return;
}
if (pretty_print)
{
auto subitem_type = val.m_value.array->cbegin()->m_type;
bool full_pretty_print = subitem_type == value_t::array ||
subitem_type == value_t::object ||
std::any_of(val.m_value.array->cbegin(), val.m_value.array->cend(),
[subitem_type](auto & subIte

最低0.47元/天 解锁文章
2630

被折叠的 条评论
为什么被折叠?



