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

commonMain.io.github.gaaabliz.kliz.common.util.JsonUtils.kt Maven / Gradle / Ivy

package io.github.gaaabliz.kliz.common.util

import com.google.gson.Gson
import com.google.gson.GsonBuilder
import org.json.JSONObject
import java.lang.reflect.Type

object JsonUtils {

    fun  convertJsonToObj(stringJson : String, outputType : Type) : T {
        val json = JSONObject(stringJson)
        return Gson().fromJson(json.toString(), outputType)
    }

    fun  convertObjToJson(objectToConvert : T) : String  {
        val gson: Gson = GsonBuilder().setPrettyPrinting().create()
        return gson.toJson(objectToConvert)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy