{"id":26022981,"url":"https://github.com/agrison/jtoml","last_synced_at":"2025-03-06T10:37:41.129Z","repository":{"id":7099030,"uuid":"8390954","full_name":"agrison/jtoml","owner":"agrison","description":"TOML for Java","archived":false,"fork":false,"pushed_at":"2021-11-04T11:46:05.000Z","size":376,"stargazers_count":48,"open_issues_count":6,"forks_count":13,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-16T07:13:10.542Z","etag":null,"topics":[],"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/agrison.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":"2013-02-24T13:25:39.000Z","updated_at":"2024-02-10T02:20:20.000Z","dependencies_parsed_at":"2022-08-28T01:20:19.178Z","dependency_job_id":null,"html_url":"https://github.com/agrison/jtoml","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agrison%2Fjtoml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agrison%2Fjtoml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agrison%2Fjtoml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agrison%2Fjtoml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agrison","download_url":"https://codeload.github.com/agrison/jtoml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242194632,"owners_count":20087620,"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":[],"created_at":"2025-03-06T10:37:40.452Z","updated_at":"2025-03-06T10:37:41.104Z","avatar_url":"https://github.com/agrison.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"TOML for Java\n===\nThis is a parser for Tom Preson-Werner's (@mojombo) [TOML](https://github.com/toml-lang/toml) markup language, using Java.\n\n[![Build Status](https://travis-ci.org/agrison/jtoml.png?branch=master)](https://travis-ci.org/agrison/jtoml)\n\nGet it\n----\n\njtoml is published in the sonatype nexus repository.\nIn order to use it, you may add this repository in your `pom.xml`:\n\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejtoml\u003c/id\u003e\n        \u003curl\u003ehttps://raw.github.com/agrison/jtoml/mvn-repo/\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\nAdd the jtoml dependency:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eme.grison\u003c/groupId\u003e\n  \u003cartifactId\u003ejtoml\u003c/artifactId\u003e\n  \u003cversion\u003e1.1.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n**Note**: The library is hosted on GitHub.\n\n\nUsage\n----\n\n### Parsing\n\n```java\nToml toml = Toml.parse(\"pi = 3.14\\nfoo = \\\"bar\\\"\"); // parse a String\ntoml = Toml.parse(new File(\"foo.toml\")); // or a file\n```\n\n### Getting values\n\nThe `Toml` class support different types of getters so that you can retrieve a specific type or the underlying `Object` without casting.\n\n```java\n// get different types\ntoml.get(\"foo\"); // Object\ntoml.getString(\"foo\"); // String\ntoml.getBoolean(\"foo\"); // Boolean\ntoml.getDate(\"foo\"); // Calendar\ntoml.getDouble(\"foo\"); // Double\ntoml.getLong(\"foo\"); // Long\ntoml.getList(\"foo\"); // List\u003cObject\u003e\ntoml.getMap(\"foo\"); // Map\u003cString, Object\u003e\n```\n\n### Mapping custom types\n\nYou can map a custom type from an entire TOML String or part of it.\nLet's say you would like to map the following TOML to a `Player` entity.\n\n```toml\n[player]\nnickName = \"foo\"\nscore = 42\n```\n\nYou could do it as simple as following:\n```java\n// or Custom objects\npublic class Player {\n    String name;\n    Long score;\n}\nToml toml = Toml.parse(\"[player]\\nname = \\\"foo\\\"\\nscore = 42\");\nPlayer player = toml.getAs(\"player\", Player.class);\nplayer.name; // \"foo\"\nplayer.score; // 42L\n```\n\n**Note:** Supported types are `Long`, `String`, `Double`, `Boolean`, `Calendar`, `List`, `Map` or Objects having the pre-cited types only.\n\n### Serialization\n\nJToml supports also serialization. Indeed, you can serialize a custom type to a String having the TOML format representing the original object.\nImagine the following custom Objects:\n\n```java\npublic class Stats {\n    Long maxSpeed;\n    Double weight;\n    // Constructors\n}\n\npublic class Car {\n    String brand;\n    String model;\n    Stats stats;\n    Boolean legendary;\n    Calendar date;\n    List\u003cString\u003e options;\n    // Constructors\n}\n\nCar f12Berlinetta = new Car(\"Ferrari\", \"F12 Berlinetta\", true, \"2012-02-29\",\n    360, 1525.5, Arrays.asList(\"GPS\", \"Leather\", \"Nitro\")\n);\nString toml = Toml.serialize(\"f12b\", f12Berlinetta);\n```\n\nThe call to `Toml.serialize()` will produce the following TOML format:\n```toml\n[f12b]\nbrand = \"Ferrari\"\nmodel = \"F12 Berlinetta\"\nlegendary = true\ndate = 2012-02-29T00:00:00Z\noptions = [\"GPS\", \"Leather\", \"Nitro\"]\n\n[f12b.stats]\nmaxSpeed = 347\nweight = 1525.5\n```\n\nYou can also serialize the current instance of a `Toml` object:\n```java\nToml toml = Toml.parse(\"[player]\\nname = \\\"foo\\\"\\nscore = 42\");\ntoml.serialize();\n```\n\nWill produce the following TOML String\n```toml\n[player]\nname = \"foo\"\nscore = 42\n```\n\n**Note:** Like for custom types above, supported types are `Long`, `String`, `Double`, `Boolean`, `Calendar`, `List`, `Map` or Objects having the pre-cited types only.\n\n\n### Support\n\nShould normally support everything in the Toml Spec.\n\n\nLicense\n-----\n[MIT License (MIT)](http://opensource.org/licenses/mit-license.php).\n\nSee the [`LICENSE`](https://github.com/agrison/jtoml/blob/master/LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagrison%2Fjtoml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagrison%2Fjtoml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagrison%2Fjtoml/lists"}