I need convert ParseObject to Json and in other time convert the Json back in ParseObject,but when I use Gson for example, don't work.
I try any forms,but no have success,my class is this:
class MyClass{
private var obj:ParseObject?=null
....gets/sets using this object
}
i need convert the obj.
Thankss;)
try
fun fromObject(data: MyObject?): String? {
data ?: return null
return Gson().toJson(data, object : TypeToken<MyObject>() {}.type)
}
fun toObject(string: String?): MyObject? {
string ?: return null
return Gson().fromJson<MyObject>(string, object : TypeToken<MyObject>() {}.type)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.