This commit is contained in:
DBotThePony 2023-05-08 09:22:15 +07:00
parent 73e082aeea
commit d5bbd717b6
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -32,6 +32,10 @@ class Codec2Serializer<T : Any>(val codec: Codec<T>, val embed: Boolean = true)
} }
override fun deserialize(p_79323_: JsonObject, p_79324_: JsonDeserializationContext): T { override fun deserialize(p_79323_: JsonObject, p_79324_: JsonDeserializationContext): T {
return codec.fromJsonStrict(p_79323_["value"] ?: throw JsonSyntaxException("Missing 'value' element")) if (embed) {
return codec.fromJsonStrict(p_79323_)
} else {
return codec.fromJsonStrict(p_79323_["value"] ?: throw JsonSyntaxException("Missing 'value' element"))
}
} }
} }