Skip to content

Commit

Permalink
Don't use objectmapper for strings in deserialize (#307)
Browse files Browse the repository at this point in the history
Co-authored-by: nsimonides <[email protected]>
  • Loading branch information
nsmnds and nsimonides authored Dec 9, 2024
1 parent 04eb553 commit 1ef2d54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ open class WirespecSerializationConfiguration {

override fun <T : Any> deserialize(raw: String?, valueType: Type?): T? = raw?.let {
when {
valueType == String::class.java -> {
@Suppress("UNCHECKED_CAST")
raw as T
}
isStringIterable(valueType) -> {
@Suppress("UNCHECKED_CAST")
raw.split(stringListDelimiter) as T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ open class WirespecSerializationConfiguration {
}

override fun <T> deserialize(raw: String, kType: KType): T =
if (isStringIterable(kType)) {
raw.split(stringListDelimiter) as T
} else {
wirespecObjectMapper
when {
kType.classifier == String::class -> raw as T
isStringIterable(kType) -> raw.split(stringListDelimiter) as T
else -> wirespecObjectMapper
.constructType(kType.javaType)
.let { wirespecObjectMapper.readValue(raw, it) }
}
Expand Down

0 comments on commit 1ef2d54

Please sign in to comment.