diff options
author | Alex Crichton <alex@alexcrichton.com> | 2017-02-11 09:13:28 -0800 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2017-02-11 09:13:33 -0800 |
commit | fba7778782193f0d0899f82d6b322da59a9044a0 (patch) | |
tree | 9530708b15876b4113194ff0ca7ad540bd204050 /src | |
parent | 3e8f87febd59b550349b1edb6cc328c9e7db3cbf (diff) | |
download | milf-rs-fba7778782193f0d0899f82d6b322da59a9044a0.tar.gz milf-rs-fba7778782193f0d0899f82d6b322da59a9044a0.zip |
Fix displaying empty arrays
Closes #145
Diffstat (limited to 'src')
-rw-r--r-- | src/value.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/value.rs b/src/value.rs index 99e6d23..4d56023 100644 --- a/src/value.rs +++ b/src/value.rs @@ -366,21 +366,19 @@ impl ser::Serialize for Value { // Be sure to visit non-tables first (and also non // array-of-tables) as all keys must be emitted first. for (k, v) in t { - if !v.is_array() && !v.is_table() { - map.serialize_key(k)?; - map.serialize_value(v)?; + if !v.is_table() && !v.is_array() || + (v.as_array().map(|a| a.len() == 0).unwrap_or(false)) { + map.serialize_entry(k, v)?; } } for (k, v) in t { - if v.is_array() { - map.serialize_key(k)?; - map.serialize_value(v)?; + if v.as_array().map(|a| a.len() > 0).unwrap_or(false) { + map.serialize_entry(k, v)?; } } for (k, v) in t { if v.is_table() { - map.serialize_key(k)?; - map.serialize_value(v)?; + map.serialize_entry(k, v)?; } } map.end() |