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.*
28
28
* val input = decoder as? JsonInput ?: throw SerializationException("This class can be loaded only by Json")
29
29
* val tree = input.decodeJson() as? JsonObject ?: throw SerializationException("Expected JsonObject")
30
30
* 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 ))
32
32
* }
33
33
*
34
34
* override fun serialize(encoder: Encoder, value: Either) {
35
35
* val output = encoder as? JsonOutput ?: throw SerializationException("This class can be saved only by Json")
36
36
* val tree = when (value) {
37
37
* 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 )
39
39
* }
40
40
* output.encodeJson(tree)
41
41
* }
Original file line number Diff line number Diff line change @@ -28,14 +28,14 @@ import kotlinx.serialization.*
28
28
* val input = decoder as? JsonInput ?: throw SerializationException("This class can be loaded only by Json")
29
29
* val tree = input.decodeJson() as? JsonObject ?: throw SerializationException("Expected JsonObject")
30
30
* 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 ))
32
32
* }
33
33
*
34
34
* override fun serialize(encoder: Encoder, value: Either) {
35
35
* val output = encoder as? JsonOutput ?: throw SerializationException("This class can be saved only by Json")
36
36
* val tree = when (value) {
37
37
* 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 )
39
39
* }
40
40
* output.encodeJson(tree)
41
41
* }
You can’t perform that action at this time.
0 commit comments