Support inline-table serialization
*Feature Request*
The current implementation of `rtoml` does not provide a way to explicitly serialize nested dictionaries as inline tables in the generated TOML output. This is a feature described in the [TOML v1.0.0 specification](https://toml.io/en/v1.0.0#inline-table).
### Example
When dumping the following dictionary:
```python
import rtoml
config = {
"database": {
"connection": {"host": "localhost", "port": 5432},
"credentials": {"user": "admin", "password": "secret"}
},
"service": {
"endpoint": "https://api.example.com",
"parameters": {"timeout": 30, "retries": 3}
}
}
with open("config.toml", "w") as f:
f.write(rtoml.dumps(config))
```
Resulting `config.toml` would be:
```toml
[database]
[database.connection]
host = "localhost"
port = 5432
[database.credentials]
user = "admin"
password = "secret"
[service]
endpoint = "https://api.example.com"
[service.parameters]
timeout = 30
retries = 3
```
### Expected output (if supported)
Imagine we had something like:
```python
rtoml.dumps(config, inline_tables={"database.connection", "database.credentials", "service.parameters"})
```
It should be possible to explicitly serialize dictionaries as inline tables, like this:
```
[database]
connection = { host = "localhost", port = 5432 }
credentials = { user = "admin", password = "secret" }
[service]
endpoint = "https://api.example.com"
parameters = { timeout = 30, retries = 3 }
```
Thank you for considering this in advance.
2 条评论