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

com.skillw.pouvoir.util.GsonUtil.kt Maven / Gradle / Ivy

There is a newer version: 1.6.7-beta-6
Show newest version
package com.skillw.pouvoir.util

import com.google.gson.Gson
import com.google.gson.GsonBuilder

/**
 * Gson工具类
 *
 * @constructor Create empty Gson utils
 */

val gson: Gson by lazy {
    GsonBuilder().serializeNulls().create()
}

inline fun  T.encodeJson(): String {
    return gson.toJson(this)
}


inline fun  String.decodeFromString(): T? {
    return gson.fromJson(this, T::class.java)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy