From 1eec20186092e6a02dd9a92ffa621853bb7df43e Mon Sep 17 00:00:00 2001 From: AJ Date: Wed, 27 Jan 2021 09:58:04 -0800 Subject: [PATCH] Update serialization version in json sample --- samples/json/build.gradle.kts | 4 ++-- .../com/github/ajalt/clikt/samples/json/JsonValueSource.kt | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/samples/json/build.gradle.kts b/samples/json/build.gradle.kts index 8f8b83624..6ab52313c 100644 --- a/samples/json/build.gradle.kts +++ b/samples/json/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("org.jetbrains.kotlin.plugin.serialization").version("1.3.72") + id("org.jetbrains.kotlin.plugin.serialization") version "1.4.10" } application { @@ -7,5 +7,5 @@ application { } dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1") } diff --git a/samples/json/src/main/kotlin/com/github/ajalt/clikt/samples/json/JsonValueSource.kt b/samples/json/src/main/kotlin/com/github/ajalt/clikt/samples/json/JsonValueSource.kt index df861f98c..7db7a49f8 100644 --- a/samples/json/src/main/kotlin/com/github/ajalt/clikt/samples/json/JsonValueSource.kt +++ b/samples/json/src/main/kotlin/com/github/ajalt/clikt/samples/json/JsonValueSource.kt @@ -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 @@ -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")