summaryrefslogtreecommitdiff
path: root/runtime/commonMain/src/kotlinx/serialization/json/Deprecated.kt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/commonMain/src/kotlinx/serialization/json/Deprecated.kt')
-rw-r--r--runtime/commonMain/src/kotlinx/serialization/json/Deprecated.kt42
1 files changed, 42 insertions, 0 deletions
diff --git a/runtime/commonMain/src/kotlinx/serialization/json/Deprecated.kt b/runtime/commonMain/src/kotlinx/serialization/json/Deprecated.kt
new file mode 100644
index 00000000..b1e6eed0
--- /dev/null
+++ b/runtime/commonMain/src/kotlinx/serialization/json/Deprecated.kt
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2017-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+@file:UseExperimental(UnstableDefault::class)
+
+package kotlinx.serialization.json
+
+import kotlinx.serialization.*
+import kotlinx.serialization.modules.*
+
+@Deprecated(deprecationText, ReplaceWith("Json"), DeprecationLevel.WARNING)
+typealias JSON = Json
+
+@Deprecated(level = DeprecationLevel.WARNING, message = "Use Json methods instead")
+class JsonTreeMapper(val encodeDefaults: Boolean = true) : AbstractSerialFormat(EmptyModule) {
+
+ @ImplicitReflectionSerializer
+ @Deprecated(level = DeprecationLevel.WARNING, message = "Use Json.fromJson instead", replaceWith = ReplaceWith("Json.plain.fromJson(tree)"))
+ inline fun <reified T : Any> readTree(tree: JsonElement): T = Json.plain.fromJson(tree)
+
+ @Deprecated(level = DeprecationLevel.WARNING, message = "Use Json.fromJson instead", replaceWith = ReplaceWith("Json.plain.fromJson(obj, deserializer)"))
+ fun <T> readTree(obj: JsonElement, deserializer: DeserializationStrategy<T>): T =
+ Json.plain.fromJson(deserializer, obj)
+
+ @Deprecated(level = DeprecationLevel.WARNING, message = "Use Json.toJson instead", replaceWith = ReplaceWith("Json.plain.toJson(obj, serializer)"))
+ fun <T> writeTree(obj: T, serializer: SerializationStrategy<T>): JsonElement = Json.plain.toJson(serializer, obj)
+}
+
+@Deprecated(level = DeprecationLevel.WARNING, message = "Use Json methods instead")
+class JsonTreeParser(private val input: String) {
+
+ companion object {
+ @Deprecated(level = DeprecationLevel.WARNING, message = "Use Json.parse instead", replaceWith = ReplaceWith("Json.plain.parseJson(input)"))
+ fun parse(input: String): JsonObject = Json.plain.parseJson(input) as JsonObject
+ }
+
+ fun readFully(): JsonElement {
+ @Suppress("DEPRECATION")
+ return Json.plain.parseJson(input)
+ }
+}