Skip to content

Commit 2785d9a

Browse files
committed
Output nested tables last
The TOML format has a restriction that if a table itself contains tables, all keys with non-table values must be emitted first. This led to the following error: $ echo '{"a": {}, "b": 1}' | rq -T [ERROR] [rq] Encountered: TOML serialize error [ERROR] [rq] Caused by: values must be emitted before tables Fix this by using tables_last to output the tables after other keys. This affects all output formats that serialize using serde. The ordering is unimportant in the other formats, so that is harmless. The performance impact should be small.
1 parent 99b4946 commit 2785d9a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎src/value/mod.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use serde_json;
66
use std::collections;
77
use std::fmt;
88
use std::io;
9+
use toml::ser as toml_ser;
910

1011
pub mod avro;
1112
pub mod cbor;
@@ -159,7 +160,7 @@ impl serde::ser::Serialize for Value {
159160
Self::Bytes(ref v) => v.serialize(s),
160161

161162
Self::Sequence(ref v) => v.serialize(s),
162-
Self::Map(ref v) => v.serialize(s),
163+
Self::Map(ref v) => toml_ser::tables_last(v, s),
163164
}
164165
}
165166
}

0 commit comments

Comments
 (0)