Kotlin extensions for Moshi, Make every thing you want with Moshi in just one line.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}dependencies {
implementation 'com.github.mazenrashed:MoshiKotlinExtensions:${LAST_VERSION}'
}data class Student(var name: String)private val studentJson = "{\"name\":\"mazen\"}"
val student: Student? = studentJson.deserialize<Student>()private val studentsJson = "[{\"name\":\"Mazen\"},{\"name\":\"Mohammad\"}]"
val students: List<Student>? = studentsJson.deserializeList()private val student: Student = Student("mazen")
val serializedObject = student.serialize()val canConvertStudentJsonToStudent: Boolean = studentJson.canConvertTo(Student::class.java) //trueMoshiExtensions.init(YOUR INSTANCE)We welcome contributions!
- ⇄ Pull requests and ★ Stars are always welcome.