{"id":19789555,"url":"https://github.com/webfreak001/mir-toml","last_synced_at":"2026-03-19T11:45:19.098Z","repository":{"id":63984157,"uuid":"571936544","full_name":"WebFreak001/mir-toml","owner":"WebFreak001","description":"Custom mir-ion (de)serializer for the TOML format","archived":false,"fork":false,"pushed_at":"2022-11-30T07:23:38.000Z","size":25,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-24T09:48:58.558Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"D","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/WebFreak001.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-29T07:54:13.000Z","updated_at":"2023-06-29T12:11:18.000Z","dependencies_parsed_at":"2023-01-14T17:30:24.226Z","dependency_job_id":null,"html_url":"https://github.com/WebFreak001/mir-toml","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/WebFreak001/mir-toml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFreak001%2Fmir-toml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFreak001%2Fmir-toml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFreak001%2Fmir-toml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFreak001%2Fmir-toml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebFreak001","download_url":"https://codeload.github.com/WebFreak001/mir-toml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFreak001%2Fmir-toml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28993252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T22:01:47.507Z","status":"ssl_error","status_checked_at":"2026-02-01T21:58:37.335Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-12T06:33:55.114Z","updated_at":"2026-02-01T22:31:09.106Z","avatar_url":"https://github.com/WebFreak001.png","language":"D","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mir-toml\n\nAs a believer of mir-ion as great general serialization framework for D, I have implemented TOML support for mir-ion.\n\n## Example\n\n```d\nimport mir.toml;\nimport mir.serde;\nimport mir.algebraic;\n\nimport std.datetime.date;\nimport std.stdio;\nimport std.file : readText;\n\nalias StringOrDouble = Algebraic!(string, double);\n\nstruct Person\n{\n    string name;\n    @serdeKeys(\"dob\")\n    Date dayOfBirth;\n}\n\nstruct Database\n{\n    bool enabled;\n    ushort[] ports;\n    StringOrDouble[][] data;\n}\n\nstruct MyDocument\n{\n    // NOTE: regular members MUST come before members that are serialized as\n    // tables or arrays of tables. (structs and struct arrays)\n    // Otherwise an exception is thrown at runtime\n    string title;\n\n    // represented as `owner = { ... }` instead of creating an `[owner]` section\n    @tomlInlineTable\n    Person owner;\n\n    Database database;\n}\n\nvoid main()\n{\n    MyDocument document = {\n        title: \"TOML Example\",\n        owner: Person(\n            \"Max Mustermann\",\n            Date(1979, 5, 27)\n        ),\n        database: Database(\n            true,\n            [8000, 8001, 8002],\n            [\n                [StringOrDouble(1.4), StringOrDouble(\"cool\")],\n                [],\n                [StringOrDouble(\"ok\")]\n            ]\n        )\n    };\n\n    writeln(serializeToml(document, TOMLBeautyConfig.full));\n\n    /* output:\n    title = \"TOML Example\"\n    owner = { name = \"Max Mustermann\", dob = 1979-05-27 }\n\n    [database]\n      enabled = true\n      ports = [ 8000, 8001, 8002 ]\n      data = [ [ 1.4, \"cool\" ], [], [ \"ok\" ] ]\n    */\n\n    // parsing TOML:\n    writeln(deserializeToml!MyDocument(readText(\"config.toml\")));\n}\n```\n\nSee also: [examples.d](./source/mir/toml/examples.d) for tested examples.\n\n## Implementation notes\n\nSerializer:\n- null values will either be omitted if possible or otherwise throw an exception at runtime\n    - exception: typed empty array null is serialized as empty array\n    - if you want to make optional fields, you should use `Variant!(void, T)` as type instead of Nullable.\n- mixing structs (tables) and other values in arrays will throw an exception at runtime if tables don't come first\n    - to fix this, annotate with `@tomlInlineArray` or change type to `TomlInlineArray!(T[])`\n- string types can be enforced using `@tomlLiteralString` (`'string'`), `@tomlMultilineString` (`\"\"\"string\"\"\"`) or `@tomlMultilineLiteralString` (`'''string'''`) - however note that runtime exceptions may occur if they are not representable\n- putting regular fields of a struct after table fields (struct members) will break at runtime\n    - planned to be fixed, to support conversion between formats, but for now not supported\n    - for serialization of D datatypes you can simply move your fields around to have the proper output, but you can't enforce this e.g. for parsed JSON\n\nDeserializer:\n- based on the `toml` library, which doesn't keep ordering of maps\n- only deserializes values, does not keep track of aesthetic things like which tables were inlined, how numbers and strings are serialized\n    - might want to somehow support this with annotations in the future\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfreak001%2Fmir-toml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebfreak001%2Fmir-toml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfreak001%2Fmir-toml/lists"}