{"id":18113870,"url":"https://github.com/jezza/toml","last_synced_at":"2025-10-04T10:14:47.292Z","repository":{"id":57720475,"uuid":"167636929","full_name":"Jezza/toml","owner":"Jezza","description":"A zero-dependency TOML library written in Java. Fast, memory efficient, and easy to use.","archived":false,"fork":false,"pushed_at":"2020-07-20T20:45:58.000Z","size":67,"stargazers_count":7,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T20:51:16.512Z","etag":null,"topics":["java","lexer","parse","toml"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/Jezza.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}},"created_at":"2019-01-26T01:35:15.000Z","updated_at":"2024-03-30T09:41:00.000Z","dependencies_parsed_at":"2022-09-26T21:41:15.898Z","dependency_job_id":null,"html_url":"https://github.com/Jezza/toml","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jezza%2Ftoml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jezza%2Ftoml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jezza%2Ftoml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jezza%2Ftoml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jezza","download_url":"https://codeload.github.com/Jezza/toml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837286,"owners_count":21169374,"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":["java","lexer","parse","toml"],"created_at":"2024-11-01T02:10:09.097Z","updated_at":"2025-10-04T10:14:42.259Z","avatar_url":"https://github.com/Jezza.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.jezza/toml/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.jezza/toml)\n\nToml\n---\n\n```java\n// TomlTable has all of the same methods has HashMap. (computeIfAbsent, put, etc)\nTomlTable table = Toml.from(new StringReader(\"key = \\\"value\\\"\"));\n```\n\n## Features:\n\n * TOML 0.5 compliant\n * Fast\n * Memory Efficient\n * Zero dependencies\n * Simple inheritance model\n\nThe main goals are simple:  \nRemain fast and lightweight.\n\nThis library has no runtime dependencies.  \nIt uses JUnit for tests, and JFlex at compile-time.\n\n### Usage\n\nThe API should be easy enough to follow.\n\nThe classes that most people will care about are: `Toml`, `TomlTable`, and `TomlArray`.\n\n\n#### `Toml`\n\nYou can use `Toml` to read a `TomlTable` from an `InputStream` or `Reader`.  \nYou can also provide an existing `TomlTable` to read into, meaning, you can chain multiple toml inputs together.\n\n#### `TomlTable`\n\nVery simply, a `HashMap`.\nIt supports dotted keys, but other than that, it's more or less exactly what you'd find in a normal `HashMap`.\n\nYou can call `asMap` to get the underlying `Map` implementation.\nAny modifications to this map will reflect in the `TomlTable` instance.\n\n#### `TomlArray`\n\nSimply an ArrayList.\nYou can perform all of the same actions.\nYou can call the `asList` method to get the underlying `List` implementation.\nAny modifications to this list will reflect in the `TomlArray` instance.\n\n\n### Values/Objects\n\nThe values you can retrieve from the collections are as follows:\n\n1) `Boolean/boolean`\n2) `Double/double`\n3) `Long/long`\n4) `String`\n5) `TomlArray`\n6) `TomlTable`\n7) `TemporalAccessor`\n\nThe only one of note is the `TemporalAccessor`.\n\nUsing it is as simple as:\n```java\nOffsetDateTime.from((TemporalAccessor) table.get(\"timestamp\"));\nLocalDateTime.from((TemporalAccessor) table.get(\"timestamp\"));\nLocalDate.from((TemporalAccessor) table.get(\"timestamp\"));\nLocalTime.from((TemporalAccessor) table.get(\"timestamp\"));\n```\n\n### Inheritance\n\nThe `Toml` class provides access to the underlying infrastructure.\n\nInheritance is as simple as:\n\n```java\nStringReader first = new StringReader(\"value = \\\"Hello, World!\\\"\");\nStringReader second = new StringReader(\"value = \\\"Bye Bye, World!\\\"\");\n\nTomlTable table = Toml.from(first, second);\n```\n\nThe inheritance model isn't _perfect_.  \nThere's a couple of pain points with it I'd like to address, but it's not critical.  \nFor example, you can't delete keys or array entries.  \nTo reduce surprises, it's best to think of it as one big input, because that's how it acts.\n\n### Language (Parser/Lexer)\n\nI've exported the lang package.  \nThat contains the parser and the lexer, should you wish to utilise them.\n\nHave fun!\n\n\n### Extension Mode\n\nThere is also a nonstandard mode, should you wish to utilise some non-standardised features.\nYou need to opt in by setting a System property.\nYou'll find the property inside of `Toml`.\n\n* Relative Table Paths.\n\nBy prepending a dot, you can refer to the previous table.\nTaking a lot of the tedium out when writing big headers. \n\n```toml\n[[items]]\nid = \"0\"\n\n# Is the same as [items.metadata]\n[.metadata]\nspecial = \"0-0\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjezza%2Ftoml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjezza%2Ftoml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjezza%2Ftoml/lists"}