{"id":13536731,"url":"https://github.com/orchestr7/ktoml","last_synced_at":"2026-04-01T18:39:19.078Z","repository":{"id":37834006,"uuid":"330720838","full_name":"orchestr7/ktoml","owner":"orchestr7","description":"Kotlin Multiplatform parser and compile-time serializer/deserializer for TOML format (Fully Native, JS, JVM) based on KxS","archived":false,"fork":false,"pushed_at":"2026-03-19T09:25:18.000Z","size":1397,"stargazers_count":543,"open_issues_count":35,"forks_count":32,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-03-20T02:39:11.363Z","etag":null,"topics":["deserialization","hacktoberfest","kotlin","kotlin-multiplatform-sample","kotlinx","kotlinx-serialization","native","serialization","toml"],"latest_commit_sha":null,"homepage":"https://orchestr7.github.io/ktoml/","language":"Kotlin","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/orchestr7.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-01-18T16:14:14.000Z","updated_at":"2026-03-18T02:20:02.000Z","dependencies_parsed_at":"2023-02-08T09:46:53.912Z","dependency_job_id":"c1302654-8e58-407b-855d-27bdbc187138","html_url":"https://github.com/orchestr7/ktoml","commit_stats":{"total_commits":193,"total_committers":17,"mean_commits":"11.352941176470589","dds":0.3471502590673575,"last_synced_commit":"0ee1a464695c99c55d8e6a4359a0968133999b86"},"previous_names":["orchestr7/ktoml","akuleshov7/ktoml"],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/orchestr7/ktoml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orchestr7%2Fktoml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orchestr7%2Fktoml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orchestr7%2Fktoml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orchestr7%2Fktoml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orchestr7","download_url":"https://codeload.github.com/orchestr7/ktoml/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orchestr7%2Fktoml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: 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":["deserialization","hacktoberfest","kotlin","kotlin-multiplatform-sample","kotlinx","kotlinx-serialization","native","serialization","toml"],"created_at":"2024-08-01T09:00:48.225Z","updated_at":"2026-04-01T18:39:16.909Z","avatar_url":"https://github.com/orchestr7.png","language":"Kotlin","funding_links":[],"categories":["Libraries"],"sub_categories":["Serializer"],"readme":"## \u003cimg src=\"/ktoml.png\" width=\"300px\"/\u003e\n\n[![Releases](https://img.shields.io/github/v/release/akuleshov7/ktoml)](https://github.com/orchestr7/ktoml/releases)\n[![Maven Central](https://img.shields.io/maven-central/v/com.akuleshov7/ktoml-core)](https://search.maven.org/artifact/com.akuleshov7/ktoml-core/)\n[![License](https://img.shields.io/github/license/akuleshov7/ktoml)](https://github.com/orchestr7/ktoml/blob/main/LICENSE)\n![Build and test](https://github.com/akuleshov7/ktoml/actions/workflows/build_and_test.yml/badge.svg?branch=main)\n![Lines of code](https://img.shields.io/tokei/lines/github/akuleshov7/ktoml)\n![Hits-of-Code](https://hitsofcode.com/github/akuleshov7/ktoml?branch=main)\n![GitHub repo size](https://img.shields.io/github/repo-size/akuleshov7/ktoml)\n![codebeat badge](https://codebeat.co/badges/0518ea49-71ed-4bfd-8dd3-62da7034eebd)\n![maintainability](https://api.codeclimate.com/v1/badges/c75d2d6b0d44cea7aefe/maintainability)\n![Run deteKT](https://github.com/akuleshov7/ktoml/actions/workflows/detekt.yml/badge.svg?branch=main)\n![Run diKTat](https://github.com/akuleshov7/ktoml/actions/workflows/diktat.yml/badge.svg?branch=main)\n\nFully Native and Multiplatform Kotlin serialization library for serialization/deserialization of [toml](https://toml.io/en/) format.\nUses native [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization), provided by Kotlin. This library contains no Java code and no Java dependencies.\nWe believe that TOML is actually the most readable and user-friendly **configuration file** format.\nSo we decided to support this format for the `kotlinx` serialization library.\n\n## Contribution\nAs this project [is needed](https://github.com/Kotlin/kotlinx.serialization/issues/1092) by the Kotlin community, we need your help.\nWe will be glad if you will test `ktoml` or contribute to this project.\nIn case you don't have much time for this - at least spend 5 seconds to give us a star to attract other contributors!\n\n**Thanks!** :pray: :partying_face:\n\n## Acknowledgement\nSpecial thanks to those awesome developers who give us great suggestions, help us to maintain and improve this project:\n@NightEule5, @bishiboosh, @Peanuuutz, @petertrr, @nulls, @Olivki, @edrd-f, @BOOMeranGG, @aSemy, @thomasgalvin\n\n## Supported platforms\nAll the code is written in Kotlin **common** module. This means that it can be built for each and every Kotlin native platform.\nHowever, to reduce the scope, ktoml now supports only the following platforms:\n- jvm\n- mingwx64\n- linuxx64\n- macosx64\n- macosArm64 (M1)\n- ios\n- iosSimulatorArm64\n- js (obviously only for ktoml-core). Note, that `js(LEGACY)` is [not supported](https://github.com/Kotlin/kotlinx.serialization/issues/1448)\n- wasmJs (obviously only for ktoml-core)\n- wasmWasi (obviously only for ktoml-core)\n\nOther platforms could be added later on the demand (just create a corresponding issue) or easily built by users on their machines.\n\n:globe_with_meridians: ktoml supports Kotlin 1.9.22\n\n## Current limitations\n:heavy_exclamation_mark: Please note, that TOML standard does not define Java-like types: `Char`, `Short`, etc. \nYou can check types that are supported in TOML standard [here](https://toml.io/en/v1.0.0#string).\nHowever, in Ktoml, our goal is to comprehensively support all primitive types offered by Kotlin.\n\n**General** \\\nWe are still developing and testing this library, so it has several limitations: \\\n:white_check_mark: deserialization (with some parsing limitations) \\\n:white_check_mark: serialization (with tree-related limitations)\n\n**Parsing and decoding** \\\n:white_check_mark: Table sections (single and dotted) \\\n:white_check_mark: Key-value pairs (single and dotted) \\\n:white_check_mark: Long/Integer/Byte/Short types \\\n:white_check_mark: Unsigned integer types \\\n:white_check_mark: Double/Float types \\\n:white_check_mark: Basic Strings \\\n:white_check_mark: Literal Strings \\\n:white_check_mark: Char type \\\n:white_check_mark: Boolean type \\\n:white_check_mark: Simple Arrays \\\n:white_check_mark: Comments \\\n:white_check_mark: Inline Tables \\\n:white_check_mark: Offset Date-Time (to `Instant` of [kotlinx-datetime](https://github.com/Kotlin/kotlinx-datetime)) \\\n:white_check_mark: Local Date-Time (to `LocalDateTime` of [kotlinx-datetime](https://github.com/Kotlin/kotlinx-datetime)) \\\n:white_check_mark: Local Date (to `LocalDate` of [kotlinx-datetime](https://github.com/Kotlin/kotlinx-datetime)) \\\n:white_check_mark: Local Time (to `LocalTime` of [kotlinx-datetime](https://github.com/Kotlin/kotlinx-datetime)) \\\n:white_check_mark: Multiline Strings \\\n:white_check_mark: Arrays (including multiline and nested arrays) \\\n:white_check_mark: Maps (for anonymous key-value pairs) \\\n:white_check_mark: Nested Inline Tables \\\n:white_check_mark: Array of Tables \\\n:white_check_mark: Inline Array of Tables \\\n:x: Arrays: of Different Types\n\n## Dependency\nThe library is hosted on the [Maven Central](https://search.maven.org/artifact/com.akuleshov7/ktoml-core).\nTo import `ktoml` library you need to add following dependencies to your code:\n\u003cdetails\u003e\n\u003csummary\u003eMaven\u003c/summary\u003e\n\n```pom\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.akuleshov7\u003c/groupId\u003e\n  \u003cartifactId\u003ektoml-core\u003c/artifactId\u003e\n  \u003cversion\u003e0.6.0\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.akuleshov7\u003c/groupId\u003e\n  \u003cartifactId\u003ektoml-file\u003c/artifactId\u003e\n  \u003cversion\u003e0.6.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eGradle Groovy\u003c/summary\u003e\n\n```groovy\nimplementation 'com.akuleshov7:ktoml-core:0.6.0'\nimplementation 'com.akuleshov7:ktoml-file:0.6.0'\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eGradle Kotlin\u003c/summary\u003e\n\n```kotlin\nimplementation(\"com.akuleshov7:ktoml-core:0.6.0\")\nimplementation(\"com.akuleshov7:ktoml-file:0.6.0\")\n```\n\u003c/details\u003e\n\n## How to use\n:heavy_exclamation_mark: as TOML is a foremost language for config files, we have also supported the deserialization from file.\nHowever, we are using [okio](https://github.com/square/okio) to read the file, so it will be added as a dependency to your\nproject if you will import [ktoml-file](https://search.maven.org/artifact/com.akuleshov7/ktoml-file). \nSame about okio `Source` (for example if you need Streaming): [ktoml-source](https://search.maven.org/artifact/com.akuleshov7/ktoml-source).\nFor basic scenarios of decoding strings you can simply use [ktoml-core](https://search.maven.org/artifact/com.akuleshov7/ktoml-core).\n\n:heavy_exclamation_mark: don't forget to add the serialization plugin `kotlin(\"plugin.serialization\")` to your project.\nOtherwise, `@Serialization` annotation won't work properly.\n\n**Deserialization:**\n\u003cdetails\u003e\n\u003csummary\u003eStraight-forward deserialization\u003c/summary\u003e\n\n```kotlin\n// add extensions from 'kotlinx' lib to your project:\nimport kotlinx.serialization.decodeFromString\nimport kotlinx.serialization.serializer\n// add com.akuleshov7:ktoml-core to your project:\nimport com.akuleshov7.ktoml.deserialize\n\n@Serializable\ndata class MyClass(/* your fields */)\n\n// to deserialize toml input in a string format (separated by newlines '\\n')\n// no need to provide serializer() explicitly if you will use extension method from\n// \u003ckotlinx.serialization.decodeFromString\u003e\nval resultFromString = Toml.decodeFromString\u003cMyClass\u003e(/* string with a toml input */)\nval resultFromList = Toml.decodeFromString\u003cMyClass\u003e(serializer(), /* sequence with lines of strings with a toml input */)\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003ePartial deserialization\u003c/summary\u003e\n\nPartial Deserialization can be useful when you would like to deserialize only **one single** table and you do not want\nto reproduce whole object structure in your code.\n\n```kotlin\n// If you need to deserialize only some part of the toml - provide the full name of the toml table. \n// The deserializer will work only with this table and it's children.\n// For example if you have the following toml, but you want only to decode [c.d.e.f] table: \n// [a]\n//   b = 1\n// [c.d.e.f]\n//   d = \"5\"\n\nval result = Toml.partiallyDecodeFromString\u003cMyClassOnlyForTable\u003e(serializer(), /* string with a toml input */, \"c.d.e.f\")\nval result = Toml.partiallyDecodeFromString\u003cMyClassOnlyForTable\u003e(serializer(), /* list with toml strings */, \"c.d.e.f\")\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eToml File deserialization\u003c/summary\u003e\n\n```kotlin\n// add com.akuleshov7:ktoml-file to your project\nimport com.akuleshov7.ktoml.file\n\nval resultFromString = TomlFileReader.decodeFromFile\u003cMyClass\u003e(serializer(), /* file path to toml file */)\nval resultFromList = TomlFileReader.partiallyDecodeFromFile\u003cMyClass\u003e(serializer(),  /* file path to toml file */, /* table name */)\n```\n\n:heavy_exclamation_mark: `toml-file` is only one of the example for reading the data from source.\nFor your particular case you can implement your own source provider based on\n[okio.Source](https://github.com/square/okio/blob/1d86391ca0ee8e5730fd0bbb6bee94c4a41ad945/okio/src/commonMain/kotlin/okio/Source.kt#L8).\nFor this purpose we have prepared `toml-source` module and implemented an \n[example](https://github.com/akuleshov7/ktoml/blob/main/ktoml-source/src/jvmMain/kotlin/com/akuleshov7/ktoml/source/JvmStreams.kt) \nwith java streams for JVM target.\n\n```kotlin\n// add com.akuleshov7:ktoml-source to your project\nimport com.akuleshov7.ktoml.source\n\nval resultFromString = TomlFileReader.decodeFromSource\u003cMyClass\u003e(serializer(), /* your source */)\nval resultFromList = TomlFileReader.partiallyDecodeFromSource\u003cMyClass\u003e(serializer(),  /* your source */, /* table name */)\n```\n\u003c/details\u003e\n\n**Serialization:**\n\u003cdetails\u003e\n\u003csummary\u003eStraight-forward serialization\u003c/summary\u003e\n\n```kotlin\n// add extensions from 'kotlinx' lib to your project:\nimport kotlinx.serialization.encodeToString\n// add com.akuleshov7:ktoml-core to your project:\nimport com.akuleshov7.ktoml.Toml\n\n@Serializable\ndata class MyClass(/* your fields */)\n\nval toml = Toml.encodeToString(MyClass(/* ... */))\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eToml File serialization\u003c/summary\u003e\n\n```kotlin\n// add com.akuleshov7:ktoml-file to your project\nimport com.akuleshov7.ktoml.file.TomlFileWriter\n\nTomlFileWriter.encodeToFile\u003cMyClass\u003e(serializer(), /* file path to toml file */)\n```\n\u003c/details\u003e\n\n**Parser to AST:**\n\u003cdetails\u003e\n\u003csummary\u003eSimple parser\u003c/summary\u003e\n\n```kotlin\nimport com.akuleshov7.ktoml.parsers.TomlParser\nimport com.akuleshov7.ktoml.TomlConfig\n/* ========= */\nvar tomlAST = TomlParser(TomlInputConfig()).parseStringsToTomlTree(/* list with toml strings */)\ntomlAST = TomlParser(TomlInputConfig()).parseString(/* the string that you want to parse */)\ntomlAST.prettyPrint()\n```\n\u003c/details\u003e\n\n### Configuration\nKtoml parsing and deserialization was made configurable to fit all the requirements from users. We have created a\nspecial configuration class that can be passed to the decoder method:\n\n```kotlin\nToml(\n    inputConfig = TomlInputConfig(\n        // allow/prohibit unknown names during the deserialization, default false\n        ignoreUnknownNames = false,\n        // allow/prohibit empty values like \"a = # comment\", default true\n        allowEmptyValues = true,\n        // allow/prohibit null values like \"a = null\", default true\n        allowNullValues = true,\n        // allow/prohibit escaping of single quotes in literal strings, default true\n        allowEscapedQuotesInLiteralStrings = true,\n        // allow/prohibit processing of empty toml, if false - throws an InternalDecodingException exception, default is true\n        allowEmptyToml = true,\n        // allow/prohibit default values during the deserialization, default is false\n        ignoreDefaultValues = false,\n    ),\n    outputConfig = TomlOutputConfig(\n        // indentation symbols for serialization, default 4 spaces\n        indentation = Indentation.FOUR_SPACES,\n    )\n).decodeFromString\u003cMyClass\u003e(\n    tomlString\n)\n```\n\n## How ktoml works: examples\n:heavy_exclamation_mark: You can check how below examples work in [decoding ReadMeExampleTest](https://github.com/akuleshov7/ktoml/blob/main/ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/decoders/ReadMeExampleTest.kt) and [encoding ReadMeExampleTest](https://github.com/akuleshov7/ktoml/blob/main/ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/encoders/ReadMeExampleTest.kt).\n\n\u003cdetails\u003e\n\u003csummary\u003eDeserialization\u003c/summary\u003e\nThe following example:\n\n```toml\nsomeBooleanProperty = true\n# inline tables in gradle 'libs.versions.toml' notation\ngradle-libs-like-property = { id = \"org.jetbrains.kotlin.jvm\", version.ref = \"kotlin\" }\n\n[table1]\n    # null is prohibited by the TOML spec, but allowed in ktoml for nullable types\n    # so for 'property1' null value is ok. Use: property1 = null  \n    property1 = 100\n    property2 = 6\n\n[myMap]\n    a = \"b\"\n    c = \"d\"\n\n[table2]\n    someNumber = 5\n[table2.\"akuleshov7.com\"]\n    name = 'this is a \"literal\" string'\n    # empty lists are also supported\n    configurationList = [\"a\",  \"b\",  \"c\"]\n\n    # such redeclaration of table2\n    # is prohibited in toml specification;\n    # but ktoml is allowing it in non-strict mode: \n    [table2]\n        otherNumber = 5.56\n        # use single quotes\n        charFromString = 'a'\n        charFromInteger = 123\n```\n\ncan be deserialized to `MyClass`:\n```kotlin\n@Serializable\ndata class MyClass(\n    val someBooleanProperty: Boolean,\n    val table1: Table1,\n    val table2: Table2,\n    @SerialName(\"gradle-libs-like-property\")\n    val kotlinJvm: GradlePlugin,\n    val myMap: Map\u003cString, String\u003e\n)\n\n@Serializable\ndata class Table1(\n    // nullable property, from toml input you can pass \"null\"/\"nil\"/\"empty\" value (no quotes needed) to this field\n    val property1: Long?,\n    // please note, that according to the specification of toml integer values should be represented with Long,\n    // but we allow to use Int/Short/etc. Just be careful with overflow\n    val property2: Byte,\n    // no need to pass this value in the input as it has the default value and so it is NOT REQUIRED\n    val property3: Short = 5\n)\n\n@Serializable\ndata class Table2(\n    val someNumber: Long,\n    @SerialName(\"akuleshov7.com\")\n    val inlineTable: NestedTable,\n    val otherNumber: Double,\n    // Char in a manner of Java/Kotlin is not supported in TOML, because single quotes are used for literal strings.\n    // However, ktoml supports reading Char from both single-char string and from it's integer code\n    val charFromString: Char,\n    val charFromInteger: Char\n)\n\n@Serializable\ndata class NestedTable(\n    val name: String,\n    @SerialName(\"configurationList\")\n    val overriddenName: List\u003cString?\u003e\n)\n\n@Serializable\ndata class GradlePlugin(val id: String, val version: Version)\n\n@Serializable\ndata class Version(val ref: String)\n```\n\nwith the following code:\n```kotlin\nToml.decodeFromString\u003cMyClass\u003e(/* your toml string */)\n```\n\nTranslation of the example above to json-terminology:\n\n```json\n{\n  \"someBooleanProperty\": true,\n  \n  \"gradle-libs-like-property\": {\n    \"id\": \"org.jetbrains.kotlin.jvm\",\n    \"version\": {\n      \"ref\": \"kotlin\"\n    }\n  },\n  \n  \"table1\": {\n    \"property1\": 100,\n    \"property2\": 5\n  },\n  \"table2\": {\n    \"someNumber\": 5,\n    \n    \"otherNumber\": 5.56,\n    \"akuleshov7.com\": {\n      \"name\": \"my name\",\n      \"configurationList\": [\n        \"a\",\n        \"b\",\n        \"c\"\n      ]\n    }\n  }\n}\n``` \n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eSerialization\u003c/summary\u003e\nThe following example from above:\n\n```toml\nsomeBooleanProperty = true\n# inline tables in gradle 'libs.versions.toml' notation\ngradle-libs-like-property = { id = \"org.jetbrains.kotlin.jvm\", version.ref = \"kotlin\" }\n\n[table1]\n# null is prohibited by the TOML spec, but allowed in ktoml for nullable types\n# so for 'property1' null value is ok. Use: property1 = null. \n# Null can also be prohibited with 'allowNullValues = false'\nproperty1 = 100\nproperty2 = 6\n\n[table2]\n    someNumber = 5\n    [table2.\"akuleshov7.com\"]\n        name = 'this is a \"literal\" string'\n        # empty lists are also supported\n        configurationList = [\"a\",  \"b\",  \"c\"]\n\n# such redeclaration of table2\n# is prohibited in toml specification;\n# but ktoml is allowing it in non-strict mode: \n[table2]\n    otherNumber = 5.56\n    # use single quotes\n    charFromString = 'a'\n    charFromInteger = 123\n```\n\ncan be serialized from `MyClass`:\n\n```kotlin\n@Serializable\ndata class MyClass(\n    val someBooleanProperty: Boolean,\n    @TomlComments(\n        \"Comments can be added\",\n        \"More comments can also be added\"\n    )\n    val table1: Table1,\n    val table2: Table2,\n   @SerialName(\"gradle-libs-like-property\")\n   val kotlinJvm: GradlePlugin\n)\n\n@Serializable\ndata class Table1(\n    @TomlComments(inline = \"At the end of lines too\")\n    // nullable values, represented as \"null\" in toml. For more strict behavior,\n    // null values can be ignored with the ignoreNullValues config property.\n    val property1: Long?,\n    // please note, that according to the specification of toml integer values should be represented with Long\n    val property2: Long,\n    // Default values can be ignored with the ignoreDefaultValues config property.\n    val property3: Long = 5\n)\n\n@Serializable\ndata class Table2(\n    // Integers can be formatted in hex, binary, etc. Currently only decimal is\n    // supported.\n    @TomlInteger(IntegerRepresentation.DECIMAL)\n    val someNumber: Long,\n    @SerialName(\"akuleshov7.com\")\n    @TomlInlineTable // Can be on the property\n    val inlineTable: InlineTable,\n    @TomlComments(\n        \"Properties always appear before sub-tables, tables aren't redeclared\"\n    )\n    val otherNumber: Double\n)\n\n@Serializable\ndata class InlineTable(\n    @TomlLiteral\n    val name: String,\n    @SerialName(\"configurationList\")\n    val overriddenName: List\u003cString?\u003e\n)\n\n@Serializable\n@TomlInlineTable // ...or the class\ndata class GradlePlugin(\n    val id: String,\n    // version is \"collapsed\": single member inline tables become dotted pairs.\n    val version: Version\n)\n\n@Serializable\n@TomlInlineTable\ndata class Version(val ref: String)\n```\n\nwith the following code:\n\n```kotlin\nToml.encodeToString\u003cMyClass\u003e(/* your encoded object */)\n```\n\u003c/details\u003e\n\n## Q\u0026A\n\n\u003cdetails\u003e\n\u003csummary\u003eI want to catch ktoml-specific exceptions in my code, how can I do it?\u003c/summary\u003e\n\nKtoml may generate various exceptions when encountering invalid input. It's important to note that certain strict checks\ncan be enabled or disabled (refer to the `Configuration` section in this readme). We have intentionally exposed only\ntwo top-level exceptions, namely `TomlDecodingException` and `TomlEncodingException`, for public use. You can catch \nthese exceptions in your code, as all other exceptions inherit from one of these two and will not be publicly accessible.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWhat if I do not know the names for keys and tables in my TOML, and therefore cannot specify a strict schema \nfor decoding? Can I still decode it somehow?\u003c/summary\u003e\n\nCertainly. In such cases, you can decode all your key-values into a `Map`. Even though your schema isn't strictly \ndefined, you need to provide type-safe structure, for example:\n\n```toml\n[a]\n    b = 42\n    c = \"String\"\n    [a.innerTable]\n        d = 5\n    [a.otherInnerTable]\n        d = \"String\"\n```\n\nIf you try to decode it using `Toml.decodeFromString\u003cMyClass\u003e(data)`:\n\n```kotlin\n@Serializable\ndata class MyClass(\n    val a: Map\u003cString, Map\u003cString, String\u003e\u003e\n)\n```\nThis will result in a `TomlDecodingException` because types of `b` and `innerTable.d` are not a `String`.\n\nAlso, it's possible to have a map of objects:\n```toml\n[coins.bitcoin]\n    scale = 8\n    default_volume = 0.1\n    skip_in_orderbook = 0.00001\n\n[coins.ethereum]\n    scale = 8\n    default_volume = 0.2\n    skip_in_orderbook = 0.00001\n\n[coins.tether]\n    scale = 2\n    default_volume = 100.0\n    skip_in_orderbook = 0.0001\n```\nYou can decode this structure using `Toml.decodeFromString\u003cCoinsConfiguration\u003e(data)` where:\n\n```kotlin\n@Serializable\ndata class Coin(\n    val scale: Long,\n    @SerialName(\"default_volume\")\n    val defaultVolume: Double,\n    @SerialName(\"skip_in_orderbook\")\n    val skipInOrderbook: Double,\n)\n@Serializable\ndata class CoinsConfiguration(\n    val coins: Map\u003cString, Coin\u003e\n)\n```\n\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forchestr7%2Fktoml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forchestr7%2Fktoml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forchestr7%2Fktoml/lists"}