Skip to content

Commit

Permalink
Update README, CHANGELOG and version
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Obser committed Sep 24, 2020
1 parent 674f14e commit c5244ae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]


## [1.0.0] - 2020-09-24
### Changed
- Compatibility with *Kotlin Serialization* `1.0.0-RC`.


## [0.2.0] - 2020-05-24
### Changed
- Compatibility with *Kotlin Serialization* `0.20.0`.
Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ open classes should be avoided.
## Gradle Dependencies
```kotlin
// Kotlin Serialization CSV
implementation("de.brudaswen.kotlinx.serialization:kotlinx-serialization-csv:0.2.0")
implementation("de.brudaswen.kotlinx.serialization:kotlinx-serialization-csv:1.0.0")

// Kotlin Serialization is added automatically, but can be added to force a specific version
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0.0-RC")
```

## Usage
Expand All @@ -28,6 +28,12 @@ of the *Kotlin Serialization* library.

### CSV Example
```kotlin
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.csv.Csv
import kotlinx.serialization.csv.CsvConfiguration

@Serializable
data class Person(val nickname: String, val name: String?, val appearance: Appearance)

Expand All @@ -37,14 +43,15 @@ data class Appearance(val gender: Gender?, val age: Int?, val height: Double?)
@Serializable
enum class Gender { MALE, FEMALE }

@OptIn(ExperimentalSerializationApi::class)
fun main() {
val csv = Csv(CsvConfiguration(hasHeaderRecord = true))

val records = listOf(
Person("Neo", "Thomas A. Anderson", Appearance(Gender.MALE, 37, 1.86)),
Person("Trinity", null, Appearance(Gender.FEMALE, null, 1.74))
)
val serialized = csv.stringify(Person.serializer().list, records)
val serialized = csv.encodeToString(ListSerializer(Person.serializer()), records)
println(serialized)
// nickname,name,appearance.gender,appearance.age,appearance.height
// Neo,Thomas A. Anderson,MALE,37,1.86
Expand All @@ -55,7 +62,7 @@ fun main() {
Neo,MALE,1.86,37,Thomas A. Anderson
Trinity,FEMALE,1.74,,
""".trimIndent().replace("\n", "\r\n")
val parsed = csv.parse(Person.serializer().list, input)
val parsed = csv.decodeFromString(ListSerializer(Person.serializer()), input)
println(parsed)
// [
// Person(nickname=Neo, name=Thomas A. Anderson, appearance=Appearance(gender=MALE, age=37, height=1.86)),
Expand Down Expand Up @@ -93,7 +100,7 @@ CSV serialization and parsing options can be changed by providing a custom `CsvC

| Dependency | Versions |
|--- |--- |
| *Kotlin Serialization* | 0.20.0 |
| *Kotlin Serialization* | 1.0.0-RC |

## License

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.2.1-SNAPSHOT
version=1.0.0-SNAPSHOT
kotlin.code.style=official

# Disable generation of metadata sha256/sha512 checksum
Expand Down

0 comments on commit c5244ae

Please sign in to comment.