Skip to content

Commit

Permalink
fixed: to_string error when array has 0 elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Ifrah committed Mar 19, 2024
1 parent 9b0c8f7 commit 9304fae
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tinyjson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,14 @@ struct element {
case element_kind::T_ARRAY: {
if(m_children.empty()) {
ss << "[]" << suffix(last_child, pretty);
} else {
ss << "[" << NEW_LINE;
for(size_t i = 0; i < m_children.size(); ++i) {
bool is_last = i == m_children.size() - 1;
m_children[i].to_string(ss, depth + 1, is_last, pretty);
}
ss << indent << "]" << suffix(last_child, pretty);
}
ss << "[" << NEW_LINE;
for(size_t i = 0; i < m_children.size(); ++i) {
bool is_last = i == m_children.size() - 1;
m_children[i].to_string(ss, depth + 1, is_last, pretty);
}
ss << indent << "]" << suffix(last_child, pretty);
} break;
case element_kind::T_INVALID:
break;
Expand Down

0 comments on commit 9304fae

Please sign in to comment.