Moshi Adapter for List<String>
.
val type = Types.newParameterizedType(List::class.java, String::class.java)val adapter = moshi.adapter<List<String>>(type)
Usage
val items = listOf("Apple", "Pear", "Banana")val jsonStr = adapter.toJson(items)val newItems = adapter.fromJson(jsonStr)
Adapter for MutableList<String>
.
val type = Types.newParameterizedType(MutableList::class.java, String::class.java)val adapter = moshi.adapter<MutableList<String>>(type)