Skip to content

Commit

Permalink
Update serialization version in json sample
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt committed Jan 27, 2021
1 parent eaa327b commit c8b4cfb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions samples/json/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id("org.jetbrains.kotlin.plugin.serialization").version("1.3.72")
id("org.jetbrains.kotlin.plugin.serialization") version "1.4.10"
}

application {
mainClass.set("com.github.ajalt.clikt.samples.json.MainKt")
}

dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.github.ajalt.clikt.core.InvalidFileFormat
import com.github.ajalt.clikt.parameters.options.Option
import com.github.ajalt.clikt.sources.ValueSource
import kotlinx.serialization.SerializationException
import kotlinx.serialization.UnstableDefault
import kotlinx.serialization.json.*
import java.io.File

Expand Down Expand Up @@ -36,7 +35,7 @@ class JsonValueSource(
if (!file.isFile) return JsonValueSource(JsonObject(emptyMap()))

val json = try {
Json(JsonConfiguration.Stable).parseJson(file.readText()) as? JsonObject
Json.parseToJsonElement(file.readText()) as? JsonObject
?: throw InvalidFileFormat(file.path, "object expected", 1)
} catch (e: SerializationException) {
if (requireValid) throw InvalidFileFormat(file.name, e.message ?: "could not read file")
Expand Down

0 comments on commit c8b4cfb

Please sign in to comment.