🛠️ToolsShed

TOML to JSON

Convert TOML configuration files to JSON and vice versa.

Sıkça Sorulan Sorular

Kod Uygulaması

# Python 3.11+: tomllib is in stdlib
import tomllib
import json

toml_text = """
[database]
host = "localhost"
port = 5432
name = "mydb"

[server]
host = "0.0.0.0"
port = 8080
debug = true

[features]
enabled = ["auth", "api", "admin"]
"""

# TOML -> JSON
data = tomllib.loads(toml_text)
json_output = json.dumps(data, indent=2)
print(json_output)

# For Python < 3.11, install tomli:
# pip install tomli
# import tomli as tomllib

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.