Skip to content

Commit e0a9a4b

Browse files
authored
Fix documentation, method was renamed from decodeJson to fromJson (#855)
1 parent fa134d9 commit e0a9a4b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ import kotlinx.serialization.*
2828
* val input = decoder as? JsonInput ?: throw SerializationException("This class can be loaded only by Json")
2929
* val tree = input.decodeJson() as? JsonObject ?: throw SerializationException("Expected JsonObject")
3030
* if ("error" in tree) return Either.Left(tree.getPrimitive("error").content)
31-
* return Either.Right(input.json.decodeJson(tree, Payload.serializer()))
31+
* return Either.Right(input.json.fromJson(Payload.serializer(), tree))
3232
* }
3333
*
3434
* override fun serialize(encoder: Encoder, value: Either) {
3535
* val output = encoder as? JsonOutput ?: throw SerializationException("This class can be saved only by Json")
3636
* val tree = when (value) {
3737
* is Either.Left -> JsonObject(mapOf("error" to JsonLiteral(value.errorMsg)))
38-
* is Either.Right -> output.json.toJson(value.data, Payload.serializer())
38+
* is Either.Right -> output.json.toJson(Payload.serializer(), value.data)
3939
* }
4040
* output.encodeJson(tree)
4141
* }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ import kotlinx.serialization.*
2828
* val input = decoder as? JsonInput ?: throw SerializationException("This class can be loaded only by Json")
2929
* val tree = input.decodeJson() as? JsonObject ?: throw SerializationException("Expected JsonObject")
3030
* if ("error" in tree) return Either.Left(tree.getPrimitive("error").content)
31-
* return Either.Right(input.json.decodeJson(tree, Payload.serializer()))
31+
* return Either.Right(input.json.fromJson(Payload.serializer(), tree))
3232
* }
3333
*
3434
* override fun serialize(encoder: Encoder, value: Either) {
3535
* val output = encoder as? JsonOutput ?: throw SerializationException("This class can be saved only by Json")
3636
* val tree = when (value) {
3737
* is Either.Left -> JsonObject(mapOf("error" to JsonLiteral(value.errorMsg)))
38-
* is Either.Right -> output.json.toJson(value.data, Payload.serializer())
38+
* is Either.Right -> output.json.toJson(Payload.serializer(), value.data)
3939
* }
4040
* output.encodeJson(tree)
4141
* }

0 commit comments

Comments
 (0)