All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.lemfi.kest.json.cli.transformers.kt Maven / Gradle / Ivy

package com.github.lemfi.kest.json.cli

import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.github.lemfi.kest.json.model.JsonArray
import com.github.lemfi.kest.json.model.JsonMap

/**
 * Transform a ByteArray to a JsonMap object
 */
@Suppress("unused")
@Deprecated("use toJsonMap instead", replaceWith = ReplaceWith("b.toJsonMap()"))
fun toJson(b: ByteArray): JsonMap {
    return jacksonObjectMapper().readValue(b, object : TypeReference() {})
}

/**
 * Transform a ByteArray to a JsonMap object
 */
@Suppress("unused")
fun ByteArray.toJsonMap(): JsonMap {
    return jacksonObjectMapper().readValue(this, object : TypeReference() {})
}

/**
 * Transform a ByteArray to a JsonMap object
 */
@Suppress("unused")
fun ByteArray.toJsonArray(): JsonArray {
    return jacksonObjectMapper().readValue(this, object : TypeReference() {})
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy