
commonMain.aws.sdk.kotlin.services.dynamodbstreams.serde.AttributeValueDocumentDeserializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.dynamodbstreams.serde
import aws.sdk.kotlin.services.dynamodbstreams.model.AttributeValue
import aws.smithy.kotlin.runtime.serde.DeserializationException
import aws.smithy.kotlin.runtime.serde.Deserializer
import aws.smithy.kotlin.runtime.serde.SdkFieldDescriptor
import aws.smithy.kotlin.runtime.serde.SdkObjectDescriptor
import aws.smithy.kotlin.runtime.serde.SerialKind
import aws.smithy.kotlin.runtime.serde.asSdkSerializable
import aws.smithy.kotlin.runtime.serde.deserializeList
import aws.smithy.kotlin.runtime.serde.deserializeMap
import aws.smithy.kotlin.runtime.serde.deserializeStruct
import aws.smithy.kotlin.runtime.serde.field
import aws.smithy.kotlin.runtime.serde.json.IgnoreKey
import aws.smithy.kotlin.runtime.serde.json.JsonDeserializer
import aws.smithy.kotlin.runtime.serde.json.JsonSerialName
import aws.smithy.kotlin.runtime.serde.serializeList
import aws.smithy.kotlin.runtime.serde.serializeMap
import aws.smithy.kotlin.runtime.serde.serializeStruct
import aws.smithy.kotlin.runtime.text.encoding.decodeBase64Bytes
import kotlin.collections.mutableListOf
import kotlin.collections.mutableMapOf
internal fun deserializeAttributeValueDocument(deserializer: Deserializer): AttributeValue {
var value: AttributeValue? = null
val B_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Blob, JsonSerialName("B"))
val BOOL_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Boolean, JsonSerialName("BOOL"))
val BS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("BS"))
val L_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("L"))
val M_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("M"))
val N_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("N"))
val NS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("NS"))
val NULL_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Boolean, JsonSerialName("NULL"))
val S_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("S"))
val SS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("SS"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
trait(IgnoreKey("__type"))
field(B_DESCRIPTOR)
field(BOOL_DESCRIPTOR)
field(BS_DESCRIPTOR)
field(L_DESCRIPTOR)
field(M_DESCRIPTOR)
field(N_DESCRIPTOR)
field(NS_DESCRIPTOR)
field(NULL_DESCRIPTOR)
field(S_DESCRIPTOR)
field(SS_DESCRIPTOR)
}
deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
loop@while(true) {
when(findNextFieldIndex()) {
B_DESCRIPTOR.index -> value = AttributeValue.B(deserializeString().decodeBase64Bytes())
BOOL_DESCRIPTOR.index -> value = AttributeValue.Bool(deserializeBoolean())
BS_DESCRIPTOR.index -> value =
deserializer.deserializeList(BS_DESCRIPTOR) {
val col0 = mutableListOf()
while (hasNextElement()) {
val el0 = if (nextHasValue()) { deserializeString().decodeBase64Bytes() } else { deserializeNull(); continue }
col0.add(el0)
}
AttributeValue.Bs(col0)
}
L_DESCRIPTOR.index -> value =
deserializer.deserializeList(L_DESCRIPTOR) {
val col0 = mutableListOf()
while (hasNextElement()) {
val el0 = if (nextHasValue()) { deserializeAttributeValueDocument(deserializer) } else { deserializeNull(); continue }
col0.add(el0)
}
AttributeValue.L(col0)
}
M_DESCRIPTOR.index -> value =
deserializer.deserializeMap(M_DESCRIPTOR) {
val map0 = mutableMapOf()
while (hasNextEntry()) {
val k0 = key()
val v0 = if (nextHasValue()) { deserializeAttributeValueDocument(deserializer) } else { deserializeNull(); continue }
map0[k0] = v0
}
AttributeValue.M(map0)
}
N_DESCRIPTOR.index -> value = AttributeValue.N(deserializeString())
NS_DESCRIPTOR.index -> value =
deserializer.deserializeList(NS_DESCRIPTOR) {
val col0 = mutableListOf()
while (hasNextElement()) {
val el0 = if (nextHasValue()) { deserializeString() } else { deserializeNull(); continue }
col0.add(el0)
}
AttributeValue.Ns(col0)
}
NULL_DESCRIPTOR.index -> value = AttributeValue.Null(deserializeBoolean())
S_DESCRIPTOR.index -> value = AttributeValue.S(deserializeString())
SS_DESCRIPTOR.index -> value =
deserializer.deserializeList(SS_DESCRIPTOR) {
val col0 = mutableListOf()
while (hasNextElement()) {
val el0 = if (nextHasValue()) { deserializeString() } else { deserializeNull(); continue }
col0.add(el0)
}
AttributeValue.Ss(col0)
}
null -> break@loop
else -> value = AttributeValue.SdkUnknown.also { skipValue() }
}
}
}
return value ?: throw DeserializationException("Deserialized union value unexpectedly null: AttributeValue")
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy