File tree Expand file tree Collapse file tree 3 files changed +5
-5
lines changed
runtime/commonMain/src/kotlinx/serialization Expand file tree Collapse file tree 3 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ import kotlinx.serialization.builtins.*
96
96
*
97
97
* ...
98
98
* override fun decodeDouble(): Double = decodeString().toDouble()
99
- * override fun decodeInt(): Double = decodeString().toInt()
99
+ * override fun decodeInt(): Int = decodeString().toInt()
100
100
* ...
101
101
* }
102
102
* ```
Original file line number Diff line number Diff line change @@ -30,14 +30,14 @@ import kotlinx.serialization.encoding.updateModeDeprecated
30
30
* val input = decoder as? JsonDecoder ?: throw SerializationException("This class can be loaded only by Json")
31
31
* val tree = input.decodeJson() as? JsonObject ?: throw SerializationException("Expected JsonObject")
32
32
* if ("error" in tree) return Either.Left(tree.getPrimitive("error").content)
33
- * return Either.Right(input.json.decodeJson(tree, Payload.serializer()))
33
+ * return Either.Right(input.json.fromJson( Payload.serializer(), tree ))
34
34
* }
35
35
*
36
36
* override fun serialize(encoder: Encoder, value: Either) {
37
37
* val output = encoder as? JsonEncoder ?: throw SerializationException("This class can be saved only by Json")
38
38
* val tree = when (value) {
39
39
* is Either.Left -> JsonObject(mapOf("error" to JsonLiteral(value.errorMsg)))
40
- * is Either.Right -> output.json.toJson(value.data, Payload.serializer())
40
+ * is Either.Right -> output.json.toJson(Payload.serializer(), value.data )
41
41
* }
42
42
* output.encodeJson(tree)
43
43
* }
Original file line number Diff line number Diff line change @@ -29,14 +29,14 @@ import kotlinx.serialization.encoding.*
29
29
* val input = decoder as? JsonDecoder ?: throw SerializationException("This class can be loaded only by Json")
30
30
* val tree = input.decodeJson() as? JsonObject ?: throw SerializationException("Expected JsonObject")
31
31
* if ("error" in tree) return Either.Left(tree.getPrimitive("error").content)
32
- * return Either.Right(input.json.decodeJson(tree, Payload.serializer()))
32
+ * return Either.Right(input.json.fromJson( Payload.serializer(), tree ))
33
33
* }
34
34
*
35
35
* override fun serialize(encoder: Encoder, value: Either) {
36
36
* val output = encoder as? JsonEncoder ?: throw SerializationException("This class can be saved only by Json")
37
37
* val tree = when (value) {
38
38
* is Either.Left -> JsonObject(mapOf("error" to JsonLiteral(value.errorMsg)))
39
- * is Either.Right -> output.json.toJson(value.data, Payload.serializer())
39
+ * is Either.Right -> output.json.toJson(Payload.serializer(), value.data )
40
40
* }
41
41
* output.encodeJson(tree)
42
42
* }
You can’t perform that action at this time.
0 commit comments