diff --git a/src/emitter.cpp b/src/emitter.cpp index 9a48318..5eb4bc4 100644 --- a/src/emitter.cpp +++ b/src/emitter.cpp @@ -410,12 +410,18 @@ namespace YAML EMITTER_STATE curState = m_pState->GetCurState(); FLOW_TYPE flowType = m_pState->GetCurGroupFlowType(); - if(flowType == FT_BLOCK) - assert(curState == ES_DONE_WITH_BLOCK_MAP_VALUE); - else if(flowType == FT_FLOW) { - m_stream << "}"; + if(flowType == FT_BLOCK) { + // Note: block sequences are *not* allowed to be empty, but we convert it + // to a flow sequence if it is + assert(curState == ES_DONE_WITH_BLOCK_MAP_VALUE || curState == ES_WAITING_FOR_BLOCK_MAP_ENTRY); + if(curState == ES_WAITING_FOR_BLOCK_MAP_ENTRY) { + unsigned curIndent = m_pState->GetCurIndent(); + m_stream << IndentTo(curIndent) << "{}"; + } + } else if(flowType == FT_FLOW) { // Note: flow maps are allowed to be empty assert(curState == ES_DONE_WITH_FLOW_MAP_VALUE || curState == ES_WAITING_FOR_FLOW_MAP_ENTRY); + m_stream << "}"; } else assert(false);