https://github.com/neuodev/intojson
Convert TOML files into JSON
https://github.com/neuodev/intojson
Last synced: about 2 months ago
JSON representation
Convert TOML files into JSON
- Host: GitHub
- URL: https://github.com/neuodev/intojson
- Owner: neuodev
- Created: 2022-08-21T14:36:43.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-21T16:08:45.000Z (almost 4 years ago)
- Last Synced: 2026-03-31T05:39:16.031Z (4 months ago)
- Language: Rust
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# IntoJSON
A tool to convert from **TOML** to **JSON**
## Example
```
$ intojson Cargo.toml
```
```json
{
"dependencies": {
"regex": "1.6.0",
"serde_json": "1.0.83"
},
"package": {
"edition": "2021",
"name": "intojson",
"version": "0.1.0"
}
}
```
For larger more complex files like [example.toml](./example.toml)
```bash
$ intojson example.toml
```
example.json
### Input
```toml
# This is a TOML document
# title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00
index = 12
[database]
enabled = true
ports = [ 8000, 8001, 8002 ]
data = [ ["delta", "phi"], [3.14] ]
temp_targets = { cpu = 79.5, case = 72.0 }
[servers]
[servers.alpha]
ip = "10.0.0.1"
role = "frontend"
[servers.beta]
ip = "10.0.0.2"
role = "backend"
```
### Output
```json
{
"database": {
"data": [["delta", "phi"], [3.14]],
"enabled": true,
"ports": [8000, 8001, 8002],
"temp_targets": {
"case": 72.0,
"cpu": 79.5
}
},
"owner": {
"dob": "1979-05-27T07:32:00-08:00",
"index": 12,
"name": "Tom Preston-Werner"
},
"servers": {},
"servers.alpha": {
"ip": "10.0.0.1",
"role": "frontend"
},
"servers.beta": {
"ip": "10.0.0.2",
"role": "backend"
}
}
```