@@ -41,11 +41,11 @@ Let us start with basic introduction to polymorphism.
41
41
42
42
### Static types
43
43
44
- Kotlin serialization is fully static with respect to types by default. The structure of encoded objects is determined
44
+ Kotlin Serialization is fully static with respect to types by default. The structure of encoded objects is determined
45
45
by * compile-time* types of objects. Let's examine this aspect in more detail and learn how
46
46
to serialize polymorphic data structures, where the type of data is determined at runtime.
47
47
48
- To show the static nature of Kotlin serialization let us make the following setup. An ` open class Project `
48
+ To show the static nature of Kotlin Serialization let us make the following setup. An ` open class Project `
49
49
has just the ` name ` property, while its derived ` class OwnedProject ` adds an ` owner ` property.
50
50
In the below example, we serialize ` data ` variable with a static type of
51
51
` Project ` that is initialized with an instance of ` OwnedProject ` at runtime.
@@ -194,7 +194,7 @@ discriminator property is not emitted into the resulting JSON.
194
194
195
195
<!-- - TEST -->
196
196
197
- In general, Kotlin serialization is designed to work correctly only when the compile-time type used during serialization
197
+ In general, Kotlin Serialization is designed to work correctly only when the compile-time type used during serialization
198
198
is the same one as the compile-time type used during deserialization. You can always specify the type explicitly
199
199
when calling serialization functions. The previous example can be corrected to use ` Project ` type for serialization
200
200
by calling ` Json.encodeToString<Project>(data) ` .
@@ -592,7 +592,7 @@ With the explicit serializer it works as before.
592
592
### Explicitly marking polymorphic class properties
593
593
594
594
The property of an interface type is implicitly considered polymorphic, since interfaces are all about runtime polymorphism.
595
- However, Kotlin serialization does not compile a serializable class with a property of a non-serializable class type.
595
+ However, Kotlin Serialization does not compile a serializable class with a property of a non-serializable class type.
596
596
If we have a property of ` Any ` class or other non-serializable class, then we must explicitly provide its serialization
597
597
strategy via the [ ` @Serializable ` ] [ Serializable ] annotation as we saw in
598
598
the [ Specifying serializer on a property] ( serializers.md#specifying-serializer-on-a-property ) section.
@@ -708,7 +708,7 @@ abstract class Response<out T>
708
708
data class OkResponse <out T >(val data : T ) : Response<T>()
709
709
```
710
710
711
- Kotlin serialization does not have a builtin strategy to represent the actually provided argument type for the
711
+ Kotlin Serialization does not have a builtin strategy to represent the actually provided argument type for the
712
712
type parameter ` T ` when serializing a property of the polymorphic type ` OkResponse<T> ` . We have to provide this
713
713
strategy explicitly when defining the serializers module for the ` Response ` . In the below example we
714
714
use ` OkResponse.serializer(...) ` to retrieve
0 commit comments