Skip to content

Instantly share code, notes, and snippets.

@qwert2603
Last active September 30, 2017 12:23
Show Gist options
  • Save qwert2603/d08e0086f5a07462d6907eb59f381063 to your computer and use it in GitHub Desktop.
Save qwert2603/d08e0086f5a07462d6907eb59f381063 to your computer and use it in GitHub Desktop.
import com.google.gson.Gson
import com.google.gson.annotations.SerializedName
data class Q @JvmOverloads constructor(
val i: Int,
@SerializedName("list") val list: List<String> = emptyList()
)
fun main(args: Array<String>) {
val gson = Gson()
val q = gson.fromJson("{\"i\": 42}", Q::class.java)
println(q)
println(q.list.size) // NPE !!!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment