File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
runtime/commonMain/src/kotlinx/serialization/json Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff 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 * }
Original file line number Diff line number Diff 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 * }
You can’t perform that action at this time.
0 commit comments