diff --git a/CHANGELOG.md b/CHANGELOG.md index feaba59..02695e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ### Added -* Serialization of objects and Toml instances to TOML. +* Support for writing objects to TOML format. * Support for underscores in numbers (the feature branch had accidentally not been merged! :( ) * Set Toml#entrySet() cf. Reflection section in README * Overloaded getters that take a default value. Thanks to __[udiabon](https://github.com/udiabon)__. diff --git a/README.md b/README.md index 54bc415..e2187f2 100644 --- a/README.md +++ b/README.md @@ -233,18 +233,9 @@ toml.containsTable("a"); // false toml.containsTableArray("a"); // false ``` -### Serialization +### Converting Objects To TOML -You can serialize a `Toml` or any arbitrary object to a TOML string. - -Once you have populated a `Toml` via `Toml.parse()`, you can serialize it back to TOML. - -```java -Toml toml = new Toml().parse("a=1"); -String tomlString = toml.serialize(); -``` - -Or you can serialize any object. +You can write any arbitrary object to a TOML `String`, `File`, `Writer`, or `OutputStream`. ```java class AClass { @@ -252,7 +243,7 @@ class AClass { int[] anArray = { 2, 3 }; } -String tomlString = Toml.serializeFrom(new AClass()); +String tomlString = new TomlWriter().write(new AClass()); /* yields: @@ -261,6 +252,8 @@ anArray = [ 2, 3 ] */ ``` +See the `TomlWriter` class for more details. + ### Limitations Date precision is limited to milliseconds.