Skip to content
Snippets Groups Projects
Commit 9973ba1c authored by Kamal Bramwell's avatar Kamal Bramwell
Browse files

Added support for decoding arrays of base64 strings

parent 28919e71
No related branches found
No related tags found
No related merge requests found
......@@ -13,8 +13,11 @@ interface BindingsModel {
}
inline fun <reified T> encodeArray(list: List<T>): ByteArray {
val data = list.map {
(it as? ByteArray)?.toBase64String() ?: it
}
val typeToken = object : TypeToken<Array<T>>() {}.type
return Gson().toJson(list.toTypedArray(), typeToken).encodeToByteArray()
return Gson().toJson(data.toTypedArray(), typeToken).encodeToByteArray()
}
inline fun <reified T> decode(data: ByteArray?): T? {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment