5
5
package kotlinx.serialization.descriptors
6
6
7
7
import kotlinx.serialization.*
8
+ import kotlinx.serialization.builtins.*
8
9
import kotlinx.serialization.encoding.*
9
10
import kotlinx.serialization.internal.*
10
11
import kotlin.reflect.*
@@ -24,22 +25,24 @@ import kotlin.reflect.*
24
25
* val nullableInt: Int?
25
26
* )
26
27
* // Descriptor for such class:
27
- * SerialDescriptor ("my.package.Data") {
28
+ * buildClassSerialDescriptor ("my.package.Data") {
28
29
* // intField is deliberately ignored by serializer -- not present in the descriptor as well
29
30
* element<Long>("_longField") // longField is named as _longField
30
- * element("stringField", listSerialDescriptor<String>())
31
+ * element("stringField", listSerialDescriptor<String>()) // or ListSerializer(String.serializer()).descriptor
31
32
* element("nullableInt", serialDescriptor<Int>().nullable)
32
33
* }
33
34
* ```
34
35
*
35
36
* Example for generic classes:
36
37
* ```
38
+ * import kotlinx.serialization.builtins.*
39
+ *
37
40
* @Serializable(CustomSerializer::class)
38
41
* class BoxedList<T>(val list: List<T>)
39
42
*
40
43
* class CustomSerializer<T>(tSerializer: KSerializer<T>): KSerializer<BoxedList<T>> {
41
44
* // here we use tSerializer.descriptor because it represents T
42
- * override val descriptor = SerialDescriptor ("pkg.BoxedList", CLASS , tSerializer.descriptor) {
45
+ * override val descriptor = buildClassSerialDescriptor ("pkg.BoxedList", tSerializer.descriptor) {
43
46
* // here we have to wrap it with List first, because property has type List<T>
44
47
* element("list", ListSerializer(tSerializer).descriptor) // or listSerialDescriptor(tSerializer.descriptor)
45
48
* }
@@ -129,7 +132,7 @@ internal class WrappedSerialDescriptor(override val serialName: String, original
129
132
* This function is left public only for migration of pre-release users and is not intended to be used
130
133
* as generally-safe and stable mechanism. Beware that it can produce inconsistent or non spec-compliant instances.
131
134
*
132
- * If you end up using this builder, please file an issue with your use-case in kotlinx.serialization
135
+ * If you end up using this builder, please file an issue with your use-case in kotlinx.serialization issue tracker.
133
136
*/
134
137
@InternalSerializationApi
135
138
@OptIn(ExperimentalSerializationApi ::class )
0 commit comments