-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature - API to write toml #1
Comments
I've actually thought about this for some time. There's a couple of issues that I'd need to resolve before I commit to a serialization API. I don't differentiate between the different types of tables beyond the parser. I don't preserve key structure. a.b.c = "asd" but without some token preserving it could be turned into: [a.b]
c = "asd" or something else bizarre. The serialiser/formatter/writer would act something like a normaliser, Comments aren't preserved at all. Adding support for comments would be a bit tricky, as I wouldn't want to pollute the data structures with So, in a nutshell, it would be possible, and as you rightfully noted, the toString() is already very similar. And comments are a whole other ball game. |
I see the problem. For my use-case, I only need to write valid toml, but not necessarily round-trip reading and writing with exact text preserved. I don't imagine that the style of written toml being undefined would be a huge issue for API users. It's certainly better than not being able to write toml at all. Maybe it would make sense to implement toml writing, with an undefined style for now, and if desired at a later time, the exact style of toml could be preserved. For comments, I'll go ahead and open a separate issue. I'm sure those would be more complicated. |
Would it be possible to have an API to write toml values back to a stream? I'm imagining a method such as
Toml.writeTo(Writer) throws IOException
I noticed from the source code that the toString() of TomlTable and TomlArray looks like it writes toml, but of course, the output of toString() is not an API guarantee.
Also, on another note, would it be possible to add comments to toml values while writing them?
The text was updated successfully, but these errors were encountered: