Hi,
First of all, tanks for the fantastic work on the 1.9.x release! I'm not sure if this is an issue or if I've simply misunderstood what the expected behavior is.
I have a data class with a List<String>? which would produce the following line in the code-gen generated adapter on 1.8.0:
14 -> genres = nullableListOfStringAdapter.fromJson(reader)
With 1.9.1 code-gen produces this:
14 -> genres = listOfStringAdapter.fromJson(reader) ?: throw Util.unexpectedNull("genres",
"genres", reader)
This results in com.squareup.moshi.JsonDataException: Required value 'genres' missing at $.programs[0].event.
Have I missed something in the 1.9.X release for marking lists as optional?
Same here. But with List<MyObject>. So looks like problem with nullable lists in general.
That does look like a bug. Can you share a code snippet? Otherwise I can probably piece together one
Here's a snippet:
@JsonClass(generateAdapter = true)
data class NullableList(
val nullableList: List<Any>?
)
val adapter = Moshi.Builder().build().adapter(NullableList::class.java)
adapter.fromJson("{}") // com.squareup.moshi.JsonDataException: Required value 'nullableList' missing at $
adapter.fromJson("""{"nullableList":null}""") // com.squareup.moshi.JsonDataException: Non-null value 'nullableList' was null at $.nullableList
I've found the issue, should have a PR shortly
Would you mind trying a snapshot build of current master to verify the fix works for you? Same for anyone else affected by this
Will do first thing in the morning! Thanks for the quick turnaround on this.
@ZacSweers Looks good on my end! Latest snapshot also resolves #991 which I was experiencing.
Great! Thanks for confirming, we'll try to get a release out shortly
On Sun, Nov 3, 2019 at 11:54 PM Hugo notifications@github.com wrote:
@ZacSweers https://github.com/ZacSweers Looks good on my end! Latest
snapshot also resolves #991 https://github.com/square/moshi/issues/991
which I was experiencing.—
You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub
https://github.com/square/moshi/issues/990?email_source=notifications&email_token=AAKMJPUD6LL2TZWEYEVOSI3QR7ILDA5CNFSM4JHGAUW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC6OOAQ#issuecomment-549250818,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAKMJPUSP6PKWWFGZAX3XZDQR7ILDANCNFSM4JHGAUWQ
.
Works for me too, thanks!
Most helpful comment
I've found the issue, should have a PR shortly