Skip to content

Commit 8928872

Browse files
committed
Merge remote-tracking branch 'origin/master' into dev
# Conflicts: # docs/custom_serializers.md # docs/json_transformations.md # docs/runtime_usage.md # runtime/commonMain/src/kotlinx/serialization/json/JsonTransformingSerializer.kt
2 parents 419ddb9 + 7b64cc7 commit 8928872

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

runtime/commonMain/src/kotlinx/serialization/encoding/Decoding.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ import kotlinx.serialization.builtins.*
9696
*
9797
* ...
9898
* override fun decodeDouble(): Double = decodeString().toDouble()
99-
* override fun decodeInt(): Double = decodeString().toInt()
99+
* override fun decodeInt(): Int = decodeString().toInt()
100100
* ...
101101
* }
102102
* ```

runtime/commonMain/src/kotlinx/serialization/json/JsonDecoder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ import kotlinx.serialization.encoding.updateModeDeprecated
3030
* val input = decoder as? JsonDecoder ?: throw SerializationException("This class can be loaded only by Json")
3131
* val tree = input.decodeJson() as? JsonObject ?: throw SerializationException("Expected JsonObject")
3232
* 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))
3434
* }
3535
*
3636
* override fun serialize(encoder: Encoder, value: Either) {
3737
* val output = encoder as? JsonEncoder ?: throw SerializationException("This class can be saved only by Json")
3838
* val tree = when (value) {
3939
* 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)
4141
* }
4242
* output.encodeJson(tree)
4343
* }

runtime/commonMain/src/kotlinx/serialization/json/JsonEncoder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ import kotlinx.serialization.encoding.*
2929
* val input = decoder as? JsonDecoder ?: throw SerializationException("This class can be loaded only by Json")
3030
* val tree = input.decodeJson() as? JsonObject ?: throw SerializationException("Expected JsonObject")
3131
* 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))
3333
* }
3434
*
3535
* override fun serialize(encoder: Encoder, value: Either) {
3636
* val output = encoder as? JsonEncoder ?: throw SerializationException("This class can be saved only by Json")
3737
* val tree = when (value) {
3838
* 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)
4040
* }
4141
* output.encodeJson(tree)
4242
* }

0 commit comments

Comments
 (0)