diff --git a/README.md b/README.md index 82835b9..ce9ada4 100644 --- a/README.md +++ b/README.md @@ -245,7 +245,9 @@ toml.containsTableArray("a"); // false ### Converting Objects To TOML -You can write any arbitrary object to a TOML `String`, `File`, `Writer`, or `OutputStream` with a `TomlWriter`. Each TomlWriter instance is customisable, immutable and threadsafe, so it can be reused and passed around. Constants and transient fields are ignored. +You can write `Map`s and custom objects to a TOML `String`, `File`, `Writer`, or `OutputStream` with a `TomlWriter`. Each TomlWriter instance is customisable, immutable and threadsafe, so it can be reused and passed around. Constants and transient fields are ignored. + +To write a `List` of objects as a table array, put the list in a `Map` or in a custom object. ```java class AClass { diff --git a/src/test/java/com/moandjiezana/toml/TomlWriterTest.java b/src/test/java/com/moandjiezana/toml/TomlWriterTest.java index 44fc986..89f1a4f 100644 --- a/src/test/java/com/moandjiezana/toml/TomlWriterTest.java +++ b/src/test/java/com/moandjiezana/toml/TomlWriterTest.java @@ -14,6 +14,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.net.URI; import java.net.URL; +import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Date; @@ -168,7 +169,7 @@ public class TomlWriterTest { } @Test - public void should_write_array_of_tables() { + public void should_write_array_of_tables_from_object() { class Table { int anInt; @@ -177,15 +178,43 @@ public class TomlWriterTest { } } class Config { - Table[] table; + Table[] table = new Table[]{new Table(1), new Table(2)}; + List