Skip to content

Commit

Permalink
Changed to allow KotlinFeature to be set in the function that registe…
Browse files Browse the repository at this point in the history
…rs a KotlinModule

from FasterXML/jackson-module-kotlin#741
  • Loading branch information
k163377 committed Dec 10, 2023
1 parent 0a594a7 commit 69cc757
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,18 @@ public fun jsonMapper(initializer: JsonMapper.Builder.() -> Unit = {}): JsonMapp
return builder.build()
}

public fun jacksonObjectMapper(): ObjectMapper = jsonMapper { addModule(kotlinModule()) }
public fun jacksonMapperBuilder(): JsonMapper.Builder = JsonMapper.builder().addModule(kotlinModule())

public fun ObjectMapper.registerKotlinModule(): ObjectMapper = this.registerModule(kotlinModule())
// region: JvmOverloads is set for bytecode compatibility for versions below 2.17.
@JvmOverloads
public fun jacksonObjectMapper(initializer: KotlinModule.Builder.() -> Unit = {}): ObjectMapper =
jsonMapper { addModule(kotlinModule(initializer)) }
@JvmOverloads
public fun jacksonMapperBuilder(initializer: KotlinModule.Builder.() -> Unit = {}): JsonMapper.Builder =
JsonMapper.builder().addModule(kotlinModule(initializer))

@JvmOverloads
public fun ObjectMapper.registerKotlinModule(initializer: KotlinModule.Builder.() -> Unit = {}): ObjectMapper =
this.registerModule(kotlinModule(initializer))
// endregion

public inline fun <reified T> jacksonTypeRef(): TypeReference<T> = object : TypeReference<T>() {}

Expand Down

0 comments on commit 69cc757

Please sign in to comment.