com.tairitsu.ignotus.support.util.JSON.kt Maven / Gradle / Ivy
package com.tairitsu.ignotus.support.util
import com.fasterxml.jackson.core.type.TypeReference
import com.tairitsu.ignotus.support.service.JSONMapperRegister
object JSON {
private val mapper
get() = JSONMapperRegister.objectMapperProvider.objectMapper
@JvmStatic
fun parseObject(content: String, clazz: Class): T? {
return mapper.readValue(content, clazz)
}
@JvmStatic
fun parseObject(content: String, type: TypeReference): T? {
return mapper.readValue(content, type)
}
@JvmStatic
fun parseObjectToMap(content: String): Map {
return mapper.readValue(content, object : TypeReference