toml-node icon indicating copy to clipboard operation
toml-node copied to clipboard

How to write TOML files?

Open bendavis78 opened this issue 3 years ago • 6 comments

How do you write a js object to a TOML file?

bendavis78 avatar Jan 07 '21 19:01 bendavis78

The TOML spec Array provide a sample write with a pseudo JSON object as element.

contributors = [
  "Foo Bar <[email protected]>",
  { name = "Baz Qux", email = "[email protected]", url = "https://example.com/bazqux" }
]

I think you can just use this object as key/value

contributors = { name = "Baz Qux", email = "[email protected]", url = "https://example.com/bazqux" }

Other solution can be usage of TOML Table

[dog."tater.man"]
type.name = "pug"

The above table should be generate the below JSON

{ "dog": { "tater.man": { "type": { "name": "pug" } } } }

Orivoir avatar Nov 22 '21 17:11 Orivoir

this lib doesn't support that

https://github.com/BinaryMuse/toml-node/blob/4bad34e1dc81586e799e269e5d2c78662b6657b2/index.js#L4-L9

micalevisk avatar Nov 28 '21 18:11 micalevisk

this lib doesn't support that

https://github.com/BinaryMuse/toml-node/blob/4bad34e1dc81586e799e269e5d2c78662b6657b2/index.js#L4-L9

Is there any lib that supports it?

dzcpy avatar Feb 13 '22 10:02 dzcpy

@dzcpy looks like this one does: https://github.com/tauri-apps/tauri-toml but the last commit was in 2019 :/

You can search for other here: https://npms.io/search?q=toml

micalevisk avatar Feb 13 '22 15:02 micalevisk

@dzcpy looks like this one does: https://github.com/tauri-apps/tauri-toml but the last commit was in 2019 :/

You can search for other here: https://npms.io/search?q=toml

Thanks for your reply. I found this one might be a better alternative. It supports TOML 0.5 https://npmjs.com/package/@iarna/toml

dzcpy avatar Feb 13 '22 17:02 dzcpy