aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-06-01 08:36:08 -0500
committerGitHub <noreply@github.com>2017-06-01 08:36:08 -0500
commit36431af975092578648225c60a8494cb0d5f6844 (patch)
tree56d5a901235aa8fb7c157c0f348b257c54fa1648 /src
parent95e1c738467c87f4072ac29923e7df399ebfe9ea (diff)
parent20dced6967398c19ae8d502bd916cc294df6a3d4 (diff)
downloadmilf-rs-36431af975092578648225c60a8494cb0d5f6844.tar.gz
milf-rs-36431af975092578648225c60a8494cb0d5f6844.zip
Merge pull request #184 from alanhdu/master
Serialize nested array of tables correctly
Diffstat (limited to 'src')
-rw-r--r--src/ser.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/ser.rs b/src/ser.rs
index 22eda81..8f6b366 100644
--- a/src/ser.rs
+++ b/src/ser.rs
@@ -308,8 +308,28 @@ impl<'a> Serializer<'a> {
State::Array { .. } => true,
_ => 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 {
- State::Table { first , .. } |
+ State::Table { first, .. } |
State::Array { parent: &State::Table { first, .. }, .. } => {
if !first.get() {
self.dst.push_str("\n");