{"id":13736384,"url":"https://github.com/NimParsers/parsetoml","last_synced_at":"2025-05-08T12:32:42.470Z","repository":{"id":25932464,"uuid":"29373791","full_name":"NimParsers/parsetoml","owner":"NimParsers","description":"A Nim library to parse TOML files","archived":false,"fork":false,"pushed_at":"2025-01-12T18:30:49.000Z","size":431,"stargazers_count":115,"open_issues_count":7,"forks_count":14,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-12T19:34:11.324Z","etag":null,"topics":["nim","parser","toml"],"latest_commit_sha":null,"homepage":"https://nimparsers.github.io/parsetoml/","language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NimParsers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-01-17T00:13:30.000Z","updated_at":"2025-01-12T18:30:38.000Z","dependencies_parsed_at":"2024-01-06T11:49:36.125Z","dependency_job_id":"f6c21b66-5978-4bad-ab16-6c19e9fafd09","html_url":"https://github.com/NimParsers/parsetoml","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NimParsers%2Fparsetoml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NimParsers%2Fparsetoml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NimParsers%2Fparsetoml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NimParsers%2Fparsetoml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NimParsers","download_url":"https://codeload.github.com/NimParsers/parsetoml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253068985,"owners_count":21848898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nim","parser","toml"],"created_at":"2024-08-03T03:01:20.787Z","updated_at":"2025-05-08T12:32:41.348Z","avatar_url":"https://github.com/NimParsers.png","language":"Nim","funding_links":[],"categories":["Data"],"sub_categories":["Parsing"],"readme":"# NimToml\n\nParsetoml is a Nim library to parse TOML files\n(https://github.com/toml-lang/toml). Currently it supports\n[v0.5.0](https://github.com/toml-lang/toml/tree/v0.5.0)\nof the TOML specification. It passes all of the validation tests in the\n[validation suite](https://github.com/BurntSushi/toml-test), including various\n0.5.0 examples.\n\n\n## Installation\n\nUse `nimble` to install it:\n\n    nimble install parsetoml\n\n## Documentation\n\nhttps://nimparsers.github.io/parsetoml/\n\n## Usage\n\nBelow are just few snippets of code to show some basic usage of this\nlibrary. Refer to the above linked documentation for complete details.\n\n### Importing the library\n\n```nim\nimport parsetoml\n```\n\n### Parsing TOML content\n\n```nim\nlet table1 = parsetoml.parseString(\"\"\"\n[input]\nfile_name = \"test.txt\"\n\n[output]\nverbose = true\n\"\"\")\nlet table2 = parsetoml.parseFile(f)\nlet table3 = parsetoml.parseFile(\"test.toml\")\n```\n\n### Using the parsed content\n\nThe return value of `parseString` and `parseFile` is a reference to\nthe `TomlValue` object, `TomlValueRef`.\n\nSeveral *getter* procs are available to query for specific types of\nfields for an input `TomlValueRef` variable:\n\n- `getStr` : Get the string value.\n- `getInt` : Get the integer value.\n- `getFloat` : Get the float value.\n- `getBool` : Get the bool value.\n- `getElems` : Get a sequence of `TomlValueRef` values.\n- `getTable` : Get a `TomlTableRef` value.\n\nUsing the same `table1` variable from the above example:\n\n```nim\n# Get the value, or fail if it is not found\nlet verboseFlag = table1[\"output\"][\"verbose\"].getBool()\n\n# You can specify a default as well\nlet input = table1[\"input\"][\"file_name\"].getStr(\"some_default.txt\")\n```\n\n### Transforming the parsed date to JSON / Table\n\nFor the validation this library needs to output JSON. Therefore it has\na proc to convert the `TomlValueRef` to JSON nodes.\n\n```nim\nimport parsetoml, json\n\nlet table1 = parsetoml.parseString(\"\"\"\n[input]\nfile_name = \"test.txt\"\n\n[output]\nverbose = true\n\"\"\")\n\necho table1.toJson.pretty()\n```\n\nAbove outputs:\n\n```json\n{\n  \"input\": {\n    \"file_name\": {\n      \"type\": \"string\",\n      \"value\": \"test.txt\"\n    }\n  },\n  \"output\": {\n    \"verbose\": {\n      \"type\": \"bool\",\n      \"value\": \"true\"\n    }\n  }\n}\n```\n\nTo see the parsed TOML in an alternative Nim AST style indented\nformat, use `parsetoml.dump(table1.getTable())` with the above\nexample, and you will get:\n\n```\ninput = table\n    file_name = string(\"test.txt\")\noutput = table\n    verbose = boolean(true)\n```\n\n## License\n\nParsetoml is released under a MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNimParsers%2Fparsetoml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNimParsers%2Fparsetoml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNimParsers%2Fparsetoml/lists"}