Skip to content

Commit

Permalink
Set github pages for ktoml project using jekyll-theme-minimal
Browse files Browse the repository at this point in the history
  • Loading branch information
orchestr7 committed Jul 11, 2021
1 parent 55d3dbd commit 04c0809
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
![Run diKTat](https://github.com/akuleshov7/ktoml/actions/workflows/diktat.yml/badge.svg)

Fully Native and Multiplatform Kotlin serialization library for serialization/deserialization of [toml](https://toml.io/en/) format.
Uses native `kotlinx.serialization`, provided by Kotlin. This library contains no Java code and no Java dependencies.
Uses native [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization), provided by Kotlin. This library contains no Java code and no Java dependencies.
We believe that TOML is actually the most readable and user-friendly **configuration file** format.
So we decided to support this format for the `kotlinx` serialization library.

Expand Down
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-slate
83 changes: 83 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
Fully Native and Multiplatform Kotlin serialization library for serialization/deserialization of [toml](https://toml.io/en/) format.
Uses native [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization), provided by Kotlin. This library contains no Java code and no Java dependencies.
We believe that TOML is actually the most readable and user-friendly *configuration file* format.
So we decided to support this format for the kotlinx serialization library.

## How ktoml works: examples

This tool natively deserializes toml expressions using native Kotlin compiler plug-in and [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/serialization-guide.md).

The following example:
```toml
someBooleanProperty = true

[table1]
property1 = 5
property2 = 6

[table2]
someNumber = 5
[table2."akuleshov7.com"]
name = "my name"
configurationList = ["a", "b", "c"]

# such redeclaration of table2
# is prohibited in toml specification;
# but ktoml is allowing it in non-strict mode:
[table2]
otherNumber = 5.56
```

can be deserialized to `MyClass`:
```kotlin
@Serializable
data class MyClass(
val someBooleanProperty: Boolean,
val table1: Table1,
val table2: Table2
)

@Serializable
data class Table1(val property1: Int, val property2: Int)

@Serializable
data class Table2(
val someNumber: Int,
@SerialName("akuleshov7.com")
val inlineTable: InlineTable,
val otherNumber: Double
)

@Serializable
data class InlineTable(
val name: String,
@SerialName("configurationList")
val overriddenName: List<String>
)
```

with the following code:
```kotlin
stringWhereTomlIsStored.deserialize<MyClass>()
```

Translation of the example above to json-terminology:
```json
{
"someBooleanProperty": true,
"table1": {
"property1": 5,
"property2": 5
},
"table2": {
"someNumber": 5,
"akuleshov7.com": {
"name": "my name",
"configurationList": ["a", "b", "c"],
"otherNumber": 5.56
}
}
}
```

You can check how this example works in [ReadMeExampleTest](ktoml-core/src/commonTest/kotlin/decoder/ReadMeExampleTest.kt).

0 comments on commit 04c0809

Please sign in to comment.