-
Notifications
You must be signed in to change notification settings - Fork 781
Add JsonClass.inline #2052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add JsonClass.inline #2052
Conversation
swankjesse
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it’s ambiguous in the case where the property is nullable?
@JsonClass(generateAdapter = true, inline = true)
data class Location(val point: Point?)Decoding [null] as a List<Location?> could be listOf(Location(null)) or listOf(null).
I think we gotta make a call here!
| } | ||
|
|
||
| @Test | ||
| fun inlineClassWithMultiplePropertiesFails() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
moshi-kotlin-tests/src/test/kotlin/com/squareup/moshi/kotlin/DualKotlinTest.kt
Outdated
Show resolved
Hide resolved
|
Prohibited nullable props in 24d409a |
Details in the changelog, but in short this unlocks the ability to match behavior like kotlinx.serialization's support for inlining the single value in JSON.
One primary question here is: what do we do about default values in this scenario? Right now it doesn't support absence
A secondary question could be to make this its own
@JsonInlineannotation rather than part of@JsonClass