This commit is contained in:
Alan Du 2017-06-01 11:38:56 +01:00
parent 2c70f6961c
commit d8cc119799

View file

@ -308,8 +308,28 @@ impl<'a> Serializer<'a> {
State::Array { .. } => true, State::Array { .. } => true,
_ => false, _ => false,
}; };
// Unlike [..]s, we can't omit [[..]] ancestors, so be sure to emit table
// headers for them.
let mut p = state;
if let State::Array { first, parent, .. } = *state {
if first.get() {
p = parent;
}
}
while let State::Table { first, parent, .. } = *p {
p = parent;
if !first.get() {
break;
}
if let State::Array { parent: &State::Table {..}, ..} = *parent {
self.emit_table_header(parent)?;
break;
}
}
match *state { match *state {
State::Table { first , .. } | State::Table { first, .. } |
State::Array { parent: &State::Table { first, .. }, .. } => { State::Array { parent: &State::Table { first, .. }, .. } => {
if !first.get() { if !first.get() {
self.dst.push_str("\n"); self.dst.push_str("\n");