Replies: 5 comments 10 replies
-
Hi, we have indeed discussed making a new release. I think @Marcono1234 had a short list of things that should ideally be included, and perhaps can comment on whether any of them are still missing. |
Beta Was this translation helpful? Give feedback.
-
I'm specifically waiting for #2401 to be part of an official build. |
Beta Was this translation helpful? Give feedback.
-
I wonder if there's any plans for GSON to support KMP ( kotlin Multiplatform ) in the near future or not? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
-
I was also thinking about #2645 as I need to do some workarounds to deal with String (de)serialization like this : Code package com.zkrallah.zhttp
import android.util.Log
import com.google.gson.Gson
import com.google.gson.JsonParseException
import com.google.gson.reflect.TypeToken
/**
* Helper function for calling the callback on the main thread.
*/
object Helper {
/**
* Deserializes the specified JSON string into an object of the specified type [T].
*
* @param json The JSON string to deserialize.
* @return The deserialized object of type [T], or `null` if the JSON string is `null`.
*/
inline fun <reified T> Gson.fromJson(json: String?): T? {
return json?.let {
val type = object : TypeToken<T>() {}.type
this.fromJson(json, type)
} ?: run {
null
}
}
/**
* Deserializes the specified JSON string into an object of the specified type [T].
*
* @param body The JSON string to deserialize.
* @return The deserialized object of type [T], or `null` if an error occurs during deserialization.
*/
inline fun <reified T> Gson.deserializeBody(body: String?): T? {
return try {
this.fromJson<T>(body)
} catch (e: JsonParseException) {
if (T::class.java == String::class.java) body as T /** HERE **/
else null
} catch (e: Exception) {
Log.e("ZHttp", "deserializeBody: $e", e)
null
}
}
} |
Beta Was this translation helpful? Give feedback.
-
2.11.0 has been released now, so I'm going to close this. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there! :)
Hopefully this is a suitable place to ask.
I'd be grateful if you could share plans for upcoming version release (it's been over a year since the last one). For what it's worth, I'm specifically waiting for #1945 and #2401 to be part of an official build.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions