The first example in Read me file is wrong?
padrecedano opened this issue · 1 comments
In the two first blocks of code of ReadMe file (here and here) you have this:
val jsonAdapter: JsonAdapter<BlackjackHand> = moshi.adapter<BlackjackHand>()
But in my case, this not compile, for me the correct way was:
val jsonAdapter = moshi.adapter(BlackjackHand::class.java)
Or:
val jsonAdapter : JsonAdapter<BlackjackHand> = moshi.adapter(BlackjackHand::class.java)
If I don't use BlackjackHand::class.java
not works, in my case.
Am I omitting some dependency and that's why it doesn't work?
If you are using the current release version of Moshi you will have to accept the code completion suggestion for the parameter-less adapter
, or manually add an import for it. This is because it's an extension function whereas the version which accepts a Type
is a member function (and thus takes precedence in completion).
In future versions (i.e., 2.0) it will be available as a member as the library is being rewritten in Kotlin.
Let me know if this resolved the problem for you, but I will preemptively close since the example is technically correct.